-
Notifications
You must be signed in to change notification settings - Fork 29.6k
New issue
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
doc, http: add Uint8Array as allowed type #45167
Conversation
OutgoingMessage.write()/end() and their derived classes support also Uint8Array besides string and Buffer.
Review requested:
|
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.
LGTM!
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.
lgtm
Perhaps we should add the first node version(s) in which they were supported as well? |
Do you know the versions? Seems this was done long time ago and not directly in HTTP instead somewhere else. I just know that the version differs between Update: it doesn't work on 14.x because #33155 was backported but #31818 was not therefore |
- version: v10.0.0 | ||
pr-url: https://github.com/nodejs/node/pull/18780 | ||
description: This method now returns a reference to `ClientRequest`. | ||
--> | ||
|
||
* `data` {string|Buffer} | ||
* `data` {string|Buffer|Uint8Array} |
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.
I'm trying to remember, are other TypedArray
types supported also? e.g. Uint16Array
, Uint32Array
, etc. If so, this should likely be updated to be TypedArray
rather than just Uint8Array
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.
According to docs e.g. fs supports this but not http, see
Lines 836 to 845 in 775bf62
if (chunk === null) { | |
throw new ERR_STREAM_NULL_VALUES(); | |
} else if (typeof chunk === 'string') { | |
len = Buffer.byteLength(chunk, encoding); | |
} else if (isUint8Array(chunk)) { | |
len = chunk.length; | |
} else { | |
throw new ERR_INVALID_ARG_TYPE( | |
'chunk', ['string', 'Buffer', 'Uint8Array'], chunk); | |
} |
Landed in 760695b |
OutgoingMessage.write()/end() and their derived classes support also Uint8Array besides string and Buffer. PR-URL: #45167 Reviewed-By: Paolo Insogna <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]>
OutgoingMessage.write()/end() and their derived classes support also Uint8Array besides string and Buffer. PR-URL: #45167 Reviewed-By: Paolo Insogna <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]>
OutgoingMessage.write()/end() and their derived classes support also Uint8Array besides string and Buffer. PR-URL: #45167 Reviewed-By: Paolo Insogna <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]>
OutgoingMessage.write()/end() and their derived classes support also Uint8Array besides string and Buffer. PR-URL: #45167 Reviewed-By: Paolo Insogna <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]>
OutgoingMessage.write()/end() and their derived classes support also Uint8Array besides string and Buffer. PR-URL: #45167 Reviewed-By: Paolo Insogna <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]>
OutgoingMessage.write()
/end()
and their derived classes support alsoUint8Array
besidesstring
andBuffer
.