-
Notifications
You must be signed in to change notification settings - Fork 29.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adjust http2 behaviour to allow ending a stream even after some data comes in (when the user has no intention of reading that data). Also correctly end a stream when trailers are present. Backport-PR-URL: #22850 PR-URL: #20621 Fixes: #20060 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
- Loading branch information
1 parent
e5f8b08
commit b0c92ca
Showing
4 changed files
with
66 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
'use strict'; | ||
|
||
// Verifies that uploading data from a client works | ||
|
||
const common = require('../common'); | ||
if (!common.hasCrypto) | ||
common.skip('missing crypto'); | ||
const assert = require('assert'); | ||
const http2 = require('http2'); | ||
const fs = require('fs'); | ||
const fixtures = require('../common/fixtures'); | ||
|
||
const loc = fixtures.path('person-large.jpg'); | ||
|
||
assert(fs.existsSync(loc)); | ||
|
||
fs.readFile(loc, common.mustCall((err, data) => { | ||
assert.ifError(err); | ||
|
||
const server = http2.createServer(common.mustCall((req, res) => { | ||
setImmediate(() => { | ||
res.writeHead(400); | ||
res.end(); | ||
}); | ||
})); | ||
|
||
server.listen(0, common.mustCall(() => { | ||
const client = http2.connect(`http://localhost:${server.address().port}`); | ||
|
||
const req = client.request({ ':method': 'POST' }); | ||
req.on('response', common.mustCall((headers) => { | ||
assert.strictEqual(headers[':status'], 400); | ||
})); | ||
|
||
req.resume(); | ||
req.on('end', common.mustCall(() => { | ||
server.close(); | ||
client.close(); | ||
})); | ||
|
||
const str = fs.createReadStream(loc); | ||
str.pipe(req); | ||
})); | ||
})); |