2017-09-04 22:29:59 -04:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
const common = require('../common');
|
|
|
|
if (!common.hasCrypto)
|
|
|
|
common.skip('missing crypto');
|
2017-10-02 21:56:53 -04:00
|
|
|
const assert = require('assert');
|
2017-09-04 22:29:59 -04:00
|
|
|
const h2 = require('http2');
|
|
|
|
|
|
|
|
// Http2ServerRequest should always end readable stream
|
|
|
|
// even on GET requests with no body
|
|
|
|
|
|
|
|
const server = h2.createServer();
|
|
|
|
server.listen(0, common.mustCall(function() {
|
|
|
|
const port = server.address().port;
|
|
|
|
server.once('request', common.mustCall(function(request, response) {
|
2017-10-02 21:56:53 -04:00
|
|
|
assert.strictEqual(request.complete, false);
|
2017-09-04 22:29:59 -04:00
|
|
|
request.on('data', () => {});
|
|
|
|
request.on('end', common.mustCall(() => {
|
2017-10-02 21:56:53 -04:00
|
|
|
assert.strictEqual(request.complete, true);
|
2017-09-04 22:29:59 -04:00
|
|
|
response.on('finish', common.mustCall(function() {
|
2019-01-21 01:22:27 +01:00
|
|
|
// The following tests edge cases on request socket
|
2017-10-02 21:56:53 -04:00
|
|
|
// right after finished fires but before backing
|
|
|
|
// Http2Stream is destroyed
|
|
|
|
assert.strictEqual(request.socket.readable, request.stream.readable);
|
|
|
|
assert.strictEqual(request.socket.readable, false);
|
|
|
|
|
2017-09-04 22:29:59 -04:00
|
|
|
server.close();
|
|
|
|
}));
|
2018-02-14 13:39:05 +00:00
|
|
|
assert.strictEqual(response.end(), response);
|
2017-09-04 22:29:59 -04:00
|
|
|
}));
|
|
|
|
}));
|
|
|
|
|
|
|
|
const url = `http://localhost:${port}`;
|
2017-12-12 11:34:17 -08:00
|
|
|
const client = h2.connect(url, common.mustCall(() => {
|
|
|
|
const request = client.request();
|
2017-09-04 22:29:59 -04:00
|
|
|
request.resume();
|
2017-12-12 11:34:17 -08:00
|
|
|
request.on('end', common.mustCall(() => {
|
|
|
|
client.close();
|
2017-09-04 22:29:59 -04:00
|
|
|
}));
|
|
|
|
}));
|
|
|
|
}));
|