mirror of https://github.com/lukechilds/node.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
799 B
31 lines
799 B
8 years ago
|
// Flags: --expose-http2
|
||
|
'use strict';
|
||
|
|
||
|
const common = require('../common');
|
||
|
const assert = require('assert');
|
||
|
const http2 = require('http2');
|
||
|
|
||
|
const server = http2.createServer();
|
||
|
server.listen(0, common.mustCall(() => {
|
||
|
const port = server.address().port;
|
||
|
server.once('request', common.mustCall((request, response) => {
|
||
|
response.addTrailers({
|
||
|
ABC: 123
|
||
|
});
|
||
|
response.end('hello');
|
||
|
}));
|
||
|
|
||
|
const url = `http://localhost:${port}`;
|
||
|
const client = http2.connect(url, common.mustCall(() => {
|
||
|
const request = client.request();
|
||
|
request.on('trailers', common.mustCall((headers) => {
|
||
|
assert.strictEqual(headers.abc, '123');
|
||
|
}));
|
||
|
request.resume();
|
||
|
request.on('end', common.mustCall(() => {
|
||
|
client.destroy();
|
||
|
server.close();
|
||
|
}));
|
||
|
}));
|
||
|
}));
|