mirror of
https://github.com/nodejs/node.git
synced 2025-05-08 14:36:08 +00:00

This helps to prevent issues where a failed test can keep a bound socket open long enough to cause other tests to fail with EADDRINUSE because the same port number is used. PR-URL: https://github.com/nodejs/node/pull/7045 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Rod Vagg <rod@vagg.org>
39 lines
886 B
JavaScript
39 lines
886 B
JavaScript
'use strict';
|
|
require('../common');
|
|
var assert = require('assert');
|
|
|
|
var http = require('http');
|
|
var net = require('net');
|
|
|
|
var gotResponse = false;
|
|
|
|
var server = net.createServer(function(conn) {
|
|
var body = 'Yet another node.js server.';
|
|
|
|
var response =
|
|
'HTTP/1.1 200 OK\r\n' +
|
|
'Connection: close\r\n' +
|
|
'Content-Length: ' + body.length + '\r\n' +
|
|
'Content-Type: text/plain;\r\n' +
|
|
' x-unix-mode=0600;\r\n' +
|
|
' name=\"hello.txt\"\r\n' +
|
|
'\r\n' +
|
|
body;
|
|
|
|
conn.end(response);
|
|
server.close();
|
|
});
|
|
|
|
server.listen(0, function() {
|
|
http.get({host: '127.0.0.1', port: this.address().port}, function(res) {
|
|
assert.equal(res.headers['content-type'],
|
|
'text/plain; x-unix-mode=0600; name="hello.txt"');
|
|
gotResponse = true;
|
|
res.destroy();
|
|
});
|
|
});
|
|
|
|
process.on('exit', function() {
|
|
assert.ok(gotResponse);
|
|
});
|