This repository has been archived by the owner on Jul 6, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
http2: add test-http2-date-header.js
- Loading branch information
1 parent
5be7c8b
commit 8a63c8e
Showing
1 changed file
with
37 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
'use strict'; | ||
require('../common'); | ||
const assert = require('assert'); | ||
const http2 = require('http2'); | ||
|
||
const testResBody = 'other stuff!\n'; | ||
|
||
const server = http2.createServer((req, res) => { | ||
assert.ok(!('date' in req.headers), | ||
'Request headers did not contain a date.'); | ||
res.writeHead(200, { | ||
'Content-Type': 'text/plain' | ||
}); | ||
res.end(testResBody); | ||
}); | ||
server.listen(0); | ||
|
||
server.on('listening', function() { | ||
const client = http2.connect(`http://localhost:${this.address().port}`); | ||
|
||
const headers = { ':path': '/' }; | ||
const req = client.request(headers).setEncoding('utf8'); | ||
|
||
req.on('response', (headers) => { | ||
assert.ok('date' in headers, | ||
'Response headers contain a date.'); | ||
|
||
req.resume(); | ||
}); | ||
|
||
req.on('end', () => { | ||
server.close(); | ||
process.exit(); | ||
}); | ||
|
||
req.end(); | ||
}); |