mirror of
https://github.com/uNetworking/uWebSockets.js.git
synced 2026-03-28 05:01:24 -04:00
Fix onDataV2 TypeScript docs to match C++ implementation (#1253)
* Initial plan * Update TypeScript docs to match C++ wrapper: rename onFullData→collectBody, onStream→onDataV2, remove maxRemainingBodyLength Co-authored-by: uNetworkingAB <110806833+uNetworkingAB@users.noreply.github.com> Agent-Logs-Url: https://github.com/uNetworking/uWebSockets.js/sessions/f459a9d8-e6c7-4fa9-b18f-011b2c04cc2e * Fix onDataV2 docstring: use accurate lead sentence and add missing JS-object-invalidation note Co-authored-by: uNetworkingAB <110806833+uNetworkingAB@users.noreply.github.com> Agent-Logs-Url: https://github.com/uNetworking/uWebSockets.js/sessions/723e9a43-c147-497d-a65e-685a5ea63cd4 * Add onDataV2 method for enhanced HTTP request handling --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: uNetworkingAB <110806833+uNetworkingAB@users.noreply.github.com>
This commit is contained in:
19
docs/index.d.ts
vendored
19
docs/index.d.ts
vendored
@@ -170,9 +170,6 @@ export interface HttpResponse {
|
||||
/** Returns the global byte write offset for this response. Use with onWritable. */
|
||||
getWriteOffset() : number;
|
||||
|
||||
/** Returns the max remaining body length of the currently read HTTP body. */
|
||||
maxRemainingBodyLength() : bigint;
|
||||
|
||||
/** Registers a handler for writable events. Continue failed write attempts in here.
|
||||
* You MUST return true for success, false for failure.
|
||||
* Writing nothing is always success, so by default you must return true.
|
||||
@@ -189,21 +186,25 @@ export interface HttpResponse {
|
||||
* Must be attached before performing any asynchronous operation, otherwise data may be lost.
|
||||
* You MUST copy the data of chunk if isLast is not true. We Neuter ArrayBuffers on return, making them zero length. */
|
||||
onData(handler: (chunk: ArrayBuffer, isLast: boolean) => void) : HttpResponse;
|
||||
|
||||
/** Pause HTTP request body streaming (throttle).
|
||||
* Some buffered data may still be sent to onData. */
|
||||
pause() : void;
|
||||
|
||||
/** Resume HTTP request body streaming (unthrottle). */
|
||||
resume() : void;
|
||||
|
||||
/** Accumulates all data chunks and calls handler with the complete body as an ArrayBuffer once all data has arrived.
|
||||
* If the total body size exceeds maxSize bytes, handler is called with null instead. */
|
||||
onFullData(maxSize: number, handler: (fullBody: ArrayBuffer | null) => void) : HttpResponse;
|
||||
collectBody(maxSize: number, handler: (fullBody: ArrayBuffer | null) => void) : HttpResponse;
|
||||
|
||||
/** Combined handler for HTTP request body streaming and connection abort events.
|
||||
* If chunk is null, the connection was aborted. If maxRemainingBodyLength is 0n, the last chunk has arrived.
|
||||
* You can safely preallocate using maxRemainingBodyLength (it is very large for chunked transfer encoding).
|
||||
* You MUST copy the data of chunk if maxRemainingBodyLength is not 0n. We Neuter ArrayBuffers on return, making them zero length. */
|
||||
onStream(handler: (chunk: ArrayBuffer | null, maxRemainingBodyLength: bigint) => void) : HttpResponse;
|
||||
/** Handler for reading HTTP request body data. V2.
|
||||
* Must be attached before performing any asynchronous operation, otherwise data may be lost.
|
||||
* You MUST copy the data of chunk if maxRemainingBodyLength is not 0. We Neuter ArrayBuffers on return, making them zero length.
|
||||
*
|
||||
* maxRemainingBodyLength is the known maximum of the remaining body length. Can be used to preallocate a receive buffer.
|
||||
*/
|
||||
onDataV2(handler: (chunk: ArrayBuffer | null, maxRemainingBodyLength: bigint) => void) : HttpResponse;
|
||||
|
||||
/** Returns the remote IP address in binary format (4 or 16 bytes). */
|
||||
getRemoteAddress() : ArrayBuffer;
|
||||
|
||||
Reference in New Issue
Block a user