Options
All
  • Public
  • Public/Protected
  • All
Menu

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.

Hierarchy

  • HttpResponse

Index

Methods

close

end

  • Ends this response by copying the contents of body.

    Parameters

    • body: string | ArrayBuffer

    Returns HttpResponse

getWriteOffset

  • getWriteOffset(): number
  • Returns the global byte write offset for this response. Use with onWritable.

    Returns number

onAborted

  • Every HttpResponse MUST have an attached abort handler IF you do not respond to it immediately inside of the callback. Returning from an Http request handler without attaching (by calling onAborted) an abort handler is ill-use and will termiante. When this event emits, the response has been aborted and may not be used.

    Parameters

    Returns HttpResponse

onData

  • Handler for reading data from POST and such requests. You MUST copy the data of chunk if isLast is not true. We Neuter ArrayBuffers on return, making it zero length.

    Parameters

    • handler: function
        • (res: HttpResponse, chunk: ArrayBuffer, isLast: boolean): void
        • Parameters

          Returns void

    Returns HttpResponse

onWritable

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

    Parameters

    Returns HttpResponse

tryEnd

  • tryEnd(fullBodyOrChunk: string, totalSize: number): [boolean, boolean]
  • Ends this response, or tries to, by streaming appropriately sized chunks of body. Use in conjunction with onWritable. Returns tuple [ok, hasResponded].

    Parameters

    • fullBodyOrChunk: string
    • totalSize: number

    Returns [boolean, boolean]

write

  • Enters or continues chunked encoding mode. Writes part of the response. End with zero length write.

    Parameters

    • chunk: string | ArrayBuffer

    Returns HttpResponse

writeHeader

  • writeHeader(key: string | ArrayBuffer, value: string | ArrayBuffer): HttpResponse
  • Writes key and value to HTTP response.

    Parameters

    • key: string | ArrayBuffer
    • value: string | ArrayBuffer

    Returns HttpResponse

writeStatus

  • Writes the HTTP status message such as "200 OK".

    Parameters

    • status: string | ArrayBuffer

    Returns HttpResponse

Generated using TypeDoc