A class representing an HTTP response to a client.

Hierarchy

  • Response

Constructors

Properties

body: string | Readable | Buffer | Uint8Array = ''

The body contents that should be written to the response.

headers: {
    [key: string]: string | string[];
} = {}

Mapping of headers that should be sent back to the client.

Type declaration

  • [key: string]: string | string[]
isBlockingWriteback: boolean = false

If this is true, then some module in the kernel has flagged the response as being interrupted and handled. Subsequent modules should NOT overwrite the response.

request: Request

The associated request object.

responseEnded: boolean = false

True if the response has been sent and closed.

sending$: BehaviorSubject<Response> = ...

Behavior subject fired right before the response content is written.

Behavior subject fired right after the response content is written.

sentHeaders: boolean = false

True if the headers have been sent.

serverResponse?: ServerResponse

The native Node.js ServerResponse.

status: HTTPStatus = HTTPStatus.OK

The HTTP status code that should be sent to the client.

Accessors

Methods

  • Add the given value as a header, appending it to an existing header if one exists.

    Parameters

    • name: string
    • value: string | string[]

    Returns Response

  • Get or set the flag for whether the writeback should be blocked.

    Parameters

    • Optional set: boolean

      if this is specified, the value will be set.

    Returns boolean

  • Returns true if the response can still be sent. False if it has been sent or the connection has been destroyed.

    Returns boolean

  • Get the value of the response header, if it exists.

    Parameters

    • name: string

    Returns undefined | string | string[]

  • Bulk set the specified headers in the response.

    Parameters

    • data: {
          [name: string]: string | string[];
      }
      • [name: string]: string | string[]

    Returns Response

  • Write the headers and specified data to the client.

    Parameters

    • data: string | Readable | Buffer | Uint8Array

    Returns Promise<void>