0
0
mirror of https://github.com/nodejs/node.git synced 2024-12-01 16:10:02 +01:00
nodejs/test/parallel/test-http-response-remove-header-after-sent.js
Weijia Wang 11a2ca29ba
errors: migrate _http_outgoing
PR-URL: https://github.com/nodejs/node/pull/14735
Refs: https://github.com/nodejs/node/issues/11273
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
2017-08-14 17:19:19 -04:00

27 lines
593 B
JavaScript

'use strict';
const common = 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');
common.expectsError(
() => res.removeHeader('header2', 2),
{
code: 'ERR_HTTP_HEADERS_SENT',
type: Error,
message: 'Cannot remove headers after they are sent to the client'
}
);
res.end();
});
server.listen(0, () => {
http.get({ port: server.address().port }, () => {
server.close();
});
});