diff --git a/docs/generated/interfaces/HttpResponse.html b/docs/generated/interfaces/HttpResponse.html index d6d51042d..12836daa6 100644 --- a/docs/generated/interfaces/HttpResponse.html +++ b/docs/generated/interfaces/HttpResponse.html @@ -1,5 +1,5 @@ HttpResponse | uWebSockets.js v20.61.0 documentation
uWebSockets.js v20.61.0 documentation
    Preparing search index...

    Interface HttpResponse

    An HttpResponse is valid until either onAborted callback or any of the .end/.tryEnd calls succeed. You may attach user data to this object.

    -
    interface HttpResponse {
        close(): HttpResponse;
        cork(cb: () => void): HttpResponse;
        end(body?: RecognizedString, closeConnection?: boolean): HttpResponse;
        endWithoutBody(
            reportedContentLength?: number,
            closeConnection?: boolean,
        ): HttpResponse;
        getProxiedRemoteAddress(): ArrayBuffer;
        getProxiedRemoteAddressAsText(): ArrayBuffer;
        getProxiedRemotePort(): number;
        getRemoteAddress(): ArrayBuffer;
        getRemoteAddressAsText(): ArrayBuffer;
        getRemotePort(): number;
        getWriteOffset(): number;
        onAborted(handler: () => void): HttpResponse;
        onData(
            handler: (chunk: ArrayBuffer, isLast: boolean) => void,
        ): HttpResponse;
        onFullData(
            maxSize: number,
            handler: (fullBody: ArrayBuffer) => void,
        ): HttpResponse;
        onWritable(handler: (offset: number) => boolean): HttpResponse;
        pause(): void;
        resume(): void;
        tryEnd(
            fullBodyOrChunk: RecognizedString,
            totalSize: number,
        ): [boolean, boolean];
        upgrade<UserData>(
            userData: UserData,
            secWebSocketKey: RecognizedString,
            secWebSocketProtocol: RecognizedString,
            secWebSocketExtensions: RecognizedString,
            context: us_socket_context_t,
        ): void;
        write(chunk: RecognizedString): boolean;
        writeHeader(key: RecognizedString, value: RecognizedString): HttpResponse;
        writeHeaders(headers: Record<string, RecognizedString>): HttpResponse;
        writeStatus(status: RecognizedString): HttpResponse;
        [key: string]: any;
    }

    Indexable

    • [key: string]: any

      Arbitrary user data may be attached to this object

      +
    interface HttpResponse {
        close(): HttpResponse;
        cork(cb: () => void): HttpResponse;
        end(body?: RecognizedString, closeConnection?: boolean): HttpResponse;
        endWithoutBody(
            reportedContentLength?: number,
            closeConnection?: boolean,
        ): HttpResponse;
        getProxiedRemoteAddress(): ArrayBuffer;
        getProxiedRemoteAddressAsText(): ArrayBuffer;
        getProxiedRemotePort(): number;
        getRemoteAddress(): ArrayBuffer;
        getRemoteAddressAsText(): ArrayBuffer;
        getRemotePort(): number;
        getWriteOffset(): number;
        onAborted(handler: () => void): HttpResponse;
        onData(
            handler: (chunk: ArrayBuffer, isLast: boolean) => void,
        ): HttpResponse;
        collectBody(
            maxSize: number,
            handler: (fullBody: ArrayBuffer) => void,
        ): HttpResponse;
        onWritable(handler: (offset: number) => boolean): HttpResponse;
        pause(): void;
        resume(): void;
        tryEnd(
            fullBodyOrChunk: RecognizedString,
            totalSize: number,
        ): [boolean, boolean];
        upgrade<UserData>(
            userData: UserData,
            secWebSocketKey: RecognizedString,
            secWebSocketProtocol: RecognizedString,
            secWebSocketExtensions: RecognizedString,
            context: us_socket_context_t,
        ): void;
        write(chunk: RecognizedString): boolean;
        writeHeader(key: RecognizedString, value: RecognizedString): HttpResponse;
        writeHeaders(headers: Record<string, RecognizedString>): HttpResponse;
        writeStatus(status: RecognizedString): HttpResponse;
        [key: string]: any;
    }

    Indexable

    • [key: string]: any

      Arbitrary user data may be attached to this object

    Index

    Methods

    Parameters

    • handler: () => void

    Returns HttpResponse

    • Handler for reading HTTP request body data. 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.

      -

      Parameters

      • handler: (chunk: ArrayBuffer, isLast: boolean) => void

      Returns HttpResponse

    • Accumulates all data chunks and calls handler with the complete body as an ArrayBuffer once all data has arrived. +

      Parameters

      • handler: (chunk: ArrayBuffer, isLast: boolean) => void

      Returns HttpResponse

    • 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.

      Parameters

      • maxSize: number
      • handler: (fullBody: ArrayBuffer) => void

      Returns HttpResponse

    • Registers a handler for writable events. Continue failed write attempts in here. You MUST return true for success, false for failure. @@ -76,4 +76,4 @@

      As you can imagine, we format outgoing responses in a linear buffer, not in a hash table. You can read about this in the user manual under "corking".

      -

      Parameters

      Returns HttpResponse

    +

    Parameters

    Returns HttpResponse

    diff --git a/docs/index.d.ts b/docs/index.d.ts index f71a0d92f..7372fd3cf 100644 --- a/docs/index.d.ts +++ b/docs/index.d.ts @@ -197,7 +197,7 @@ export interface HttpResponse { /** 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. diff --git a/src/HttpResponseWrapper.h b/src/HttpResponseWrapper.h index b6a1955df..fa5544fdd 100644 --- a/src/HttpResponseWrapper.h +++ b/src/HttpResponseWrapper.h @@ -118,7 +118,7 @@ struct HttpResponseWrapper { * accumulated into a std::vector whose memory is transferred zero-copy into the ArrayBuffer backing store. * Returns this */ template - static void res_onFullData(const FunctionCallbackInfo &args) { + static void res_collectBody(const FunctionCallbackInfo &args) { Isolate *isolate = args.GetIsolate(); auto *res = getHttpResponse(args); if (res) { @@ -639,7 +639,7 @@ struct HttpResponseWrapper { /* QUIC has a lot of functions unimplemented */ if constexpr (SSL != 2) { resTemplateLocal->PrototypeTemplate()->Set(String::NewFromUtf8(isolate, "onStream", NewStringType::kNormal).ToLocalChecked(), FunctionTemplate::New(isolate, res_onStream)); - resTemplateLocal->PrototypeTemplate()->Set(String::NewFromUtf8(isolate, "onFullData", NewStringType::kNormal).ToLocalChecked(), FunctionTemplate::New(isolate, res_onFullData)); + resTemplateLocal->PrototypeTemplate()->Set(String::NewFromUtf8(isolate, "collectBody", NewStringType::kNormal).ToLocalChecked(), FunctionTemplate::New(isolate, res_collectBody)); resTemplateLocal->PrototypeTemplate()->Set(String::NewFromUtf8(isolate, "getWriteOffset", NewStringType::kNormal).ToLocalChecked(), FunctionTemplate::New(isolate, res_getWriteOffset)); resTemplateLocal->PrototypeTemplate()->Set(String::NewFromUtf8(isolate, "maxRemainingBodyLength", NewStringType::kNormal).ToLocalChecked(), FunctionTemplate::New(isolate, res_maxRemainingBodyLength)); resTemplateLocal->PrototypeTemplate()->Set(String::NewFromUtf8(isolate, "getRemoteAddress", NewStringType::kNormal).ToLocalChecked(), FunctionTemplate::New(isolate, res_getRemoteAddress));