-
Notifications
You must be signed in to change notification settings - Fork 29.7k
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
dont throw errors on Uint8Arrays and added test for all valid types Co-authored-by: Ruben Bridgewater <ruben@bridgewater.de> fixup: remove dup fixup: remove unused dec fixup: add Uint8Array check in test fixup: don't throw invalid arg error on `Uint8Array`s
- Loading branch information
Showing
2 changed files
with
26 additions
and
1 deletion.
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
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 }); | ||
})); |