| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| 'use strict'; | ||
|
|
||
| const assert = require('assert'); | ||
| const http2 = require('http2'); | ||
|
|
||
| const common = require('../common'); | ||
| if (!common.hasCrypto) | ||
| common.skip('missing crypto'); | ||
|
|
||
| for (const chunkSequence of [ | ||
| [ '' ], | ||
| [ '', '' ] | ||
| ]) { | ||
| const server = http2.createServer(); | ||
| server.on('stream', common.mustCall((stream, headers, flags) => { | ||
| stream.respond({ 'content-type': 'text/html' }); | ||
|
|
||
| let data = ''; | ||
| stream.on('data', common.mustNotCall((chunk) => { | ||
| data += chunk.toString(); | ||
| })); | ||
| stream.on('end', common.mustCall(() => { | ||
| stream.end(`"${data}"`); | ||
| })); | ||
| })); | ||
|
|
||
| server.listen(0, common.mustCall(() => { | ||
| const port = server.address().port; | ||
| const client = http2.connect(`http://localhost:${port}`); | ||
|
|
||
| const req = client.request({ | ||
| ':method': 'POST', | ||
| ':path': '/' | ||
| }); | ||
|
|
||
| req.on('response', common.mustCall((headers) => { | ||
| assert.strictEqual(headers[':status'], 200); | ||
| assert.strictEqual(headers['content-type'], 'text/html'); | ||
| })); | ||
|
|
||
| let data = ''; | ||
| req.setEncoding('utf8'); | ||
| req.on('data', common.mustCallAtLeast((d) => data += d)); | ||
| req.on('end', common.mustCall(() => { | ||
| assert.strictEqual(data, '""'); | ||
| server.close(); | ||
| client.close(); | ||
| })); | ||
|
|
||
| for (const chunk of chunkSequence) | ||
| req.write(chunk); | ||
| req.end(); | ||
| })); | ||
| } |
| Back | FazBrowse Home | New Git URL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityOne question, if we remove the empty buffer and do nothing, will the header be sent?
Refs: https://github.com/nodejs/node/pull/18673/files#diff-696b2cc418addca5f3fe5020058f8b15R1622
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality@XadillaX Hm – I’m not sure I can wrap my head around everything, but this code here is only ever called by nghttp2 after the headers were sent anyway… does that answer your question?
So, yes, writing an empty buffer would trigger the headers to be sent, as I understand it.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.