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 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
http2: fix res.setHeader to update linkedlist APIs
PR-URL: #75 Reviewed-By: James M Snell <[email protected]>
- Loading branch information
1 parent
128fe84
commit bec7891
Showing
2 changed files
with
53 additions
and
3 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
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,39 @@ | ||
'use strict'; | ||
|
||
const common = require('../common'); | ||
const assert = require('assert'); | ||
const http2 = require('http2'); | ||
const path = require('path'); | ||
const tls = require('tls'); | ||
const net = require('net'); | ||
const fs = require('fs'); | ||
const body = | ||
'<html><head></head><body><h1>this is some data</h2></body></html>'; | ||
|
||
const server = http2.createServer((req, res) => { | ||
res.setHeader('foobar', 'baz'); | ||
res.setHeader('X-POWERED-BY', 'node-test'); | ||
res.end(body); | ||
}); | ||
|
||
server.listen(0, common.mustCall(() => { | ||
const client = http2.connect(`http://localhost:${server.address().port}`); | ||
const headers = { ':path': '/' }; | ||
const req = client.request(headers); | ||
req.setEncoding('utf8'); | ||
req.on('response', common.mustCall(function(headers) { | ||
assert.strictEqual(headers['foobar'], 'baz'); | ||
assert.strictEqual(headers['x-powered-by'], 'node-test'); | ||
})); | ||
|
||
let data = ''; | ||
req.on('data', (d) => data += d); | ||
req.on('end', () => { | ||
assert.strictEqual(body, data); | ||
server.close(); | ||
client.destroy(); | ||
}); | ||
req.end(); | ||
})); | ||
|
||
server.on('error', common.mustNotCall()); |