nodejs/test/parallel/test-http-date-header.js

36 lines
807 B
JavaScript
Raw Normal View History

'use strict';
require('../common');
const assert = require('assert');
const http = require('http');
const testResBody = 'other stuff!\n';
const server = http.createServer(function(req, res) {
assert.ok(!('date' in req.headers),
2012-02-18 15:01:35 -08:00
'Request headers contained a Date.');
res.writeHead(200, {
2012-02-18 15:01:35 -08:00
'Content-Type': 'text/plain'
});
res.end(testResBody);
});
server.listen(0);
2012-02-18 15:01:35 -08:00
server.addListener('listening', function() {
const options = {
port: this.address().port,
2012-02-18 15:01:35 -08:00
path: '/',
method: 'GET'
};
const req = http.request(options, function(res) {
2012-02-18 15:01:35 -08:00
assert.ok('date' in res.headers,
'Response headers didn\'t contain a Date.');
res.addListener('end', function() {
server.close();
process.exit();
});
2012-12-13 07:47:33 -08:00
res.resume();
});
req.end();
});