Skip to content

Commit 1b4371e

Browse files
committed
http2: add test for head request is not finished
1 parent b2e4cb7 commit 1b4371e

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
'use strict';
2+
3+
const common = require('../common');
4+
if (!common.hasCrypto)
5+
common.skip('missing crypto');
6+
const assert = require('assert');
7+
const h2 = require('http2');
8+
9+
// The purpose of this test is to ensure that res.finished is
10+
// not true before res.end() is called or the request is aborted
11+
// for HEAD requests.
12+
13+
const server = h2
14+
.createServer()
15+
.listen(0, common.mustCall(function() {
16+
const port = server.address().port;
17+
server.once('request', common.mustCall((req, res) => {
18+
assert.ok(!res.finished); // This fails.
19+
res.end();
20+
}));
21+
22+
const url = `http://localhost:${port}`;
23+
const client = h2.connect(url, common.mustCall(function() {
24+
const headers = {
25+
':path': '/',
26+
':method': 'HEAD',
27+
':scheme': 'http',
28+
':authority': `localhost:${port}`
29+
};
30+
const request = client.request(headers);
31+
request.on('end', common.mustCall(function() {
32+
client.close();
33+
}));
34+
request.end();
35+
request.resume();
36+
}));
37+
}))

0 commit comments

Comments
 (0)