mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
1fd7d8e903
PR-URL: https://github.com/nodejs/node/pull/35951 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Ricky Zhou <0x19951125@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
38 lines
936 B
JavaScript
38 lines
936 B
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
if (!common.hasCrypto) {
|
|
common.skip('missing crypto');
|
|
}
|
|
|
|
const http2 = require('http2');
|
|
const assert = require('assert');
|
|
|
|
const server = http2.createServer();
|
|
|
|
server.on('session', common.mustCall(function(session) {
|
|
session.on('stream', common.mustCall(function(stream) {
|
|
stream.on('end', common.mustCall(function() {
|
|
this.respond({
|
|
':status': 200
|
|
});
|
|
this.write('foo');
|
|
this.destroy();
|
|
}));
|
|
stream.resume();
|
|
}));
|
|
}));
|
|
|
|
server.listen(0, function() {
|
|
const client = http2.connect(`http://localhost:${server.address().port}`);
|
|
const stream = client.request({ ':method': 'POST' });
|
|
stream.on('response', common.mustCall(function(headers) {
|
|
assert.strictEqual(headers[':status'], 200);
|
|
}));
|
|
stream.on('close', common.mustCall(() => {
|
|
client.close();
|
|
server.close();
|
|
}));
|
|
stream.resume();
|
|
stream.end();
|
|
});
|