Skip to content
This repository was archived by the owner on Jul 6, 2018. It is now read-only.

Commit c6f37ae

Browse files
http2: add test-http2-date-header.js
1 parent 5be7c8b commit c6f37ae

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
'use strict';
2+
3+
require('../common');
4+
const assert = require('assert');
5+
const http2 = require('http2');
6+
7+
const testResBody = 'other stuff!\n';
8+
9+
const server = http2.createServer((req, res) => {
10+
assert.ok(!('date' in req.headers),
11+
'Request headers did not contain a date.');
12+
res.writeHead(200, {
13+
'Content-Type': 'text/plain'
14+
});
15+
res.end(testResBody);
16+
});
17+
server.listen(0);
18+
19+
server.on('listening', function() {
20+
const client = http2.connect(`http://localhost:${this.address().port}`);
21+
22+
const headers = { ':path': '/' };
23+
const req = client.request(headers).setEncoding('utf8');
24+
25+
req.on('response', (headers) => {
26+
assert.ok('date' in headers,
27+
'Response headers contain a date.');
28+
29+
req.resume();
30+
});
31+
32+
req.on('end', () => {
33+
server.close();
34+
process.exit();
35+
});
36+
37+
req.end();
38+
});

0 commit comments

Comments
 (0)