diff options
author | Anatoli Papirovski <apapirovski@mac.com> | 2017-09-04 22:29:59 -0400 |
---|---|---|
committer | Myles Borins <mylesborins@google.com> | 2017-09-12 03:18:26 +0200 |
commit | 764213cc7bbb4b0d20824e729a0b9cf00ca2cb3d (patch) | |
tree | d7eb767f89c6bd0ee854c50090b424d9bfe97f34 /test/parallel/test-http2-compat-serverrequest-end.js | |
parent | ddbcc9e59d8abb8af8851b968f7a1ec981896bf7 (diff) | |
download | node-new-764213cc7bbb4b0d20824e729a0b9cf00ca2cb3d.tar.gz |
http2: add compat trailers, adjust multi-headers
Adds Http2ServerRequest trailers & rawTrailers functionality. Also fixes
behaviour of multi-headers to conform with the spec (all values but
set-cookie and cookie should be comma delimited, cookie should be
semi-colon delimited and only set-cookie should be an array). Adds
setter for statusMessage that warns, for backwards compatibility.
End readable side of the stream on trailers or bodyless requests
Refs: https://github.com/expressjs/express/pull/3390#discussion_r136718729
PR-URL: https://github.com/nodejs/node/pull/15193
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Diffstat (limited to 'test/parallel/test-http2-compat-serverrequest-end.js')
-rw-r--r-- | test/parallel/test-http2-compat-serverrequest-end.js | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/test/parallel/test-http2-compat-serverrequest-end.js b/test/parallel/test-http2-compat-serverrequest-end.js new file mode 100644 index 0000000000..a84f73883d --- /dev/null +++ b/test/parallel/test-http2-compat-serverrequest-end.js @@ -0,0 +1,40 @@ +// Flags: --expose-http2 +'use strict'; + +const common = require('../common'); +if (!common.hasCrypto) + common.skip('missing crypto'); +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) { + request.on('data', () => {}); + request.on('end', common.mustCall(() => { + response.on('finish', common.mustCall(function() { + server.close(); + })); + response.end(); + })); + })); + + const url = `http://localhost:${port}`; + const client = h2.connect(url, common.mustCall(function() { + const headers = { + ':path': '/foobar', + ':method': 'GET', + ':scheme': 'http', + ':authority': `localhost:${port}` + }; + const request = client.request(headers); + request.resume(); + request.on('end', common.mustCall(function() { + client.destroy(); + })); + request.end(); + })); +})); |