-
Notifications
You must be signed in to change notification settings - Fork 30k
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: #33490 PR-URL: #33155 Fixes: #33379 Refs: #29829 Reviewed-By: Robert Nagy <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Zeyu Yang <[email protected]> Reviewed-By: James M Snell <[email protected]>
- Loading branch information
1 parent
b6ef6c8
commit feb6e1f
Showing
3 changed files
with
29 additions
and
4 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 }); | ||
})); |