forked from nodejs/node
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
http: don't throw on
Uint8Array
s for http.ServerResponse#write
Don't throw errors on Uint8Arrays and added test for all valid types. Backport-PR-URL: nodejs#33488 PR-URL: nodejs#33155 Fixes: nodejs#33379 Refs: nodejs#29829 Reviewed-By: Robert Nagy <ronagy@icloud.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Zeyu Yang <himself65@outlook.com> Reviewed-By: James M Snell <jasnell@gmail.com>
- Loading branch information
Showing
3 changed files
with
53 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
'use strict'; | ||
const common = require('../common'); | ||
const assert = require('assert'); | ||
const http = require('http'); | ||
|
||
const httpServer = http.createServer(common.mustCall(function(req, res) { | ||
httpServer.close(); | ||
assert.throws(() => { | ||
res.write(['Throws.']); | ||
}, { | ||
code: 'ERR_INVALID_ARG_TYPE' | ||
}); | ||
// should not throw | ||
res.write('1a2b3c'); | ||
// should not throw | ||
res.write(new Uint8Array(1024)); | ||
// should not throw | ||
res.write(Buffer.from('1'.repeat(1024))); | ||
res.end(); | ||
})); | ||
|
||
httpServer.listen(0, common.mustCall(function() { | ||
http.get({ port: this.address().port }); | ||
})); |