Skip to content
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

Merged
merged 2 commits into from
Oct 27, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 26 additions & 6 deletions doc/api/http.md
Original file line number Diff line number Diff line change
Expand Up @@ -750,12 +750,15 @@ See [`writable.cork()`][].
<!-- YAML
added: v0.1.90
changes:
- version: v15.0.0
pr-url: https://github.com/nodejs/node/pull/33155
description: The `data` parameter can now be a `Uint8Array`.
- 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}
Copy link
Member

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

Copy link
Member Author

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

node/lib/_http_outgoing.js

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);
}

* `encoding` {string}
* `callback` {Function}
* Returns: {this}
Expand Down Expand Up @@ -1205,9 +1208,13 @@ before the [`'finish'`][] event is emitted.

<!-- YAML
added: v0.1.29
changes:
- version: v15.0.0
pr-url: https://github.com/nodejs/node/pull/33155
description: The `chunk` parameter can now be a `Uint8Array`.
-->

* `chunk` {string|Buffer}
* `chunk` {string|Buffer|Uint8Array}
* `encoding` {string}
* `callback` {Function}
* Returns: {boolean}
Expand Down Expand Up @@ -1740,12 +1747,15 @@ See [`writable.cork()`][].
<!-- YAML
added: v0.1.90
changes:
- version: v15.0.0
pr-url: https://github.com/nodejs/node/pull/33155
description: The `data` parameter can now be a `Uint8Array`.
- version: v10.0.0
pr-url: https://github.com/nodejs/node/pull/18780
description: This method now returns a reference to `ServerResponse`.
-->

* `data` {string|Buffer}
* `data` {string|Buffer|Uint8Array}
* `encoding` {string}
* `callback` {Function}
* Returns: {this}
Expand Down Expand Up @@ -2094,9 +2104,13 @@ before the [`'finish'`][] event is emitted.

<!-- YAML
added: v0.1.29
changes:
- version: v15.0.0
pr-url: https://github.com/nodejs/node/pull/33155
description: The `chunk` parameter can now be a `Uint8Array`.
-->

* `chunk` {string|Buffer}
* `chunk` {string|Buffer|Uint8Array}
* `encoding` {string} **Default:** `'utf8'`
* `callback` {Function}
* Returns: {boolean}
Expand Down Expand Up @@ -2784,11 +2798,14 @@ and is connected, that socket will be destroyed as well.
<!-- YAML
added: v0.1.90
changes:
- version: v15.0.0
pr-url: https://github.com/nodejs/node/pull/33155
description: The `chunk` parameter can now be a `Uint8Array`.
- version: v0.11.6
description: add `callback` argument.
-->

* `chunk` {string | Buffer}
* `chunk` {string|Buffer|Uint8Array}
* `encoding` {string} Optional, **Default**: `utf8`
* `callback` {Function} Optional
* Returns: {this}
Expand Down Expand Up @@ -3044,11 +3061,14 @@ Always `false`.
<!-- YAML
added: v0.1.29
changes:
- version: v15.0.0
pr-url: https://github.com/nodejs/node/pull/33155
description: The `chunk` parameter can now be a `Uint8Array`.
- version: v0.11.6
description: The `callback` argument was added.
-->

* `chunk` {string | Buffer}
* `chunk` {string|Buffer|Uint8Array}
* `encoding` {string} **Default**: `utf8`
* `callback` {Function}
* Returns {boolean}
Expand Down