mirror of https://github.com/lukechilds/node.git
Browse Source
This change adds tests to make sure an Error is thrown if a header is added or removed after they are sent. PR-URL: https://github.com/nodejs/node/pull/8682 Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Ilkka Myller <ilkka.myller@nodefield.com>v6.x
Niklas Ingholt
8 years ago
committed by
Jeremiah Senkpiel
2 changed files with 42 additions and 0 deletions
@ -0,0 +1,21 @@ |
|||||
|
'use strict'; |
||||
|
require('../common'); |
||||
|
const assert = require('assert'); |
||||
|
const http = require('http'); |
||||
|
|
||||
|
const server = http.createServer((req, res) => { |
||||
|
assert.doesNotThrow(() => { |
||||
|
res.setHeader('header1', 1); |
||||
|
}); |
||||
|
res.write('abc'); |
||||
|
assert.throws(() => { |
||||
|
res.setHeader('header2', 2); |
||||
|
}, /Can't set headers after they are sent\./); |
||||
|
res.end(); |
||||
|
}); |
||||
|
|
||||
|
server.listen(0, () => { |
||||
|
http.get({port: server.address().port}, () => { |
||||
|
server.close(); |
||||
|
}); |
||||
|
}); |
@ -0,0 +1,21 @@ |
|||||
|
'use strict'; |
||||
|
require('../common'); |
||||
|
const assert = require('assert'); |
||||
|
const http = require('http'); |
||||
|
|
||||
|
const server = http.createServer((req, res) => { |
||||
|
assert.doesNotThrow(() => { |
||||
|
res.removeHeader('header1', 1); |
||||
|
}); |
||||
|
res.write('abc'); |
||||
|
assert.throws(() => { |
||||
|
res.removeHeader('header2', 2); |
||||
|
}, /Can't remove headers after they are sent/); |
||||
|
res.end(); |
||||
|
}); |
||||
|
|
||||
|
server.listen(0, () => { |
||||
|
http.get({port: server.address().port}, () => { |
||||
|
server.close(); |
||||
|
}); |
||||
|
}); |
Loading…
Reference in new issue