mirror of
https://github.com/nodejs/node.git
synced 2025-05-02 18:44:40 +00:00

Extensive re-work of http1 compatibility layer based on tests in express, on-finished and finalhandler. Fix handling of HEAD method to match http1. Adjust write, end, etc. to call writeHead as in http1 and as expected by user-land modules. Add socket proxy that instead uses the Http2Stream for the vast majority of socket interactions. Add and change tests to closer represent http1 behaviour. Refs: https://github.com/nodejs/node/pull/15633 Refs: https://github.com/expressjs/express/tree/master/test Refs: https://github.com/jshttp/on-finished/blob/master/test/test.js Refs: https://github.com/pillarjs/finalhandler/blob/master/test/test.js PR-URL: https://github.com/nodejs/node/pull/15702 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
29 lines
706 B
JavaScript
29 lines
706 B
JavaScript
'use strict';
|
|
|
|
const common = require('../common');
|
|
if (!common.hasCrypto)
|
|
common.skip('missing crypto');
|
|
const assert = require('assert');
|
|
const http2 = require('http2');
|
|
|
|
let client;
|
|
let req;
|
|
const server = http2.createServer();
|
|
server.on('stream', common.mustCall((stream) => {
|
|
stream.on('error', common.mustCall(() => {
|
|
stream.on('streamClosed', common.mustCall((code) => {
|
|
assert.strictEqual(code, 2);
|
|
client.destroy();
|
|
server.close();
|
|
}));
|
|
}));
|
|
|
|
req.rstStream(2);
|
|
}));
|
|
server.listen(0, common.mustCall(() => {
|
|
client = http2.connect(`http://localhost:${server.address().port}`);
|
|
req = client.request();
|
|
req.resume();
|
|
req.on('error', common.mustCall());
|
|
}));
|