mirror of
https://github.com/nodejs/node.git
synced 2026-11-24 21:50:36 -05:00
ESLint 4.x has stricter linting than previous versions. We are currently using the legacy indentation rules in the test directory. This commit changes the indentation of files to comply with the stricter 4.x linting and enable stricter linting in the test directory. Backport-PR-URL: https://github.com/nodejs/node/pull/14835 PR-URL: https://github.com/nodejs/node/pull/14431 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com> Reviewed-By: Trevor Norris <trev.norris@gmail.com>
36 lines
932 B
JavaScript
36 lines
932 B
JavaScript
'use strict';
|
|
require('../common');
|
|
const assert = require('assert');
|
|
const http = require('http');
|
|
|
|
// Verify that ServerResponse.getHeader() works correctly even after
|
|
// the response header has been sent. Issue 752 on github.
|
|
|
|
const s = http.createServer(function(req, res) {
|
|
const contentType = 'Content-Type';
|
|
const plain = 'text/plain';
|
|
res.setHeader(contentType, plain);
|
|
assert.ok(!res.headersSent);
|
|
res.writeHead(200);
|
|
assert.ok(res.headersSent);
|
|
res.end('hello world\n');
|
|
// This checks that after the headers have been sent, getHeader works
|
|
// and does not throw an exception (Issue 752)
|
|
assert.doesNotThrow(
|
|
function() {
|
|
assert.strictEqual(plain, res.getHeader(contentType));
|
|
}
|
|
);
|
|
});
|
|
|
|
s.listen(0, runTest);
|
|
|
|
function runTest() {
|
|
http.get({ port: this.address().port }, function(response) {
|
|
response.on('end', function() {
|
|
s.close();
|
|
});
|
|
response.resume();
|
|
});
|
|
}
|