User-agent response class.

Hierarchy

  • Body
    • UserAgentResponse

Constructors

Properties

_form: undefined | Params = undefined
_stream: Readable
autoDecompress: boolean = true

Automatically decompress message body if necessary.

headers: Headers

HTTP headers.

httpVersion: string

HTTP version.

statusCode: number

Response status code.

statusMessage: string

Response status message.

Accessors

  • get _params(): Params
  • Returns Params

  • get isClientError(): boolean
  • Check if response has a 4xx response status code.

    Returns boolean

  • get isError(): boolean
  • Check if response has a 4xx or 5xx response status code.

    Returns boolean

  • get isRedirect(): boolean
  • Check if response has a 3xx response status code.

    Returns boolean

  • get isServerError(): boolean
  • Check if response has a 5xx response status code.

    Returns boolean

  • get isSuccess(): boolean
  • Check if response has a 2xx response status code.

    Returns boolean

  • get type(): null | string
  • Get Content-Type header value.

    Returns null | string

Methods

  • Returns AsyncIterable<Buffer>

  • Returns Promise<Uint8Array[]>

  • Parameters

    • Optional options: UploadOptions

    Returns AsyncIterableIterator<[string, Readable, string, string, string]>

  • Returns boolean

  • Get message body as Buffer object.

    Returns Promise<Buffer>

  • Get message body as a readable stream.

    Returns Readable

  • Get async iterator for uploaded files from message body.

    Parameters

    • Optional options: UploadOptions

    Returns AsyncIterableIterator<FileUpload>

  • Get form parameters from message body.

    Parameters

    • Optional options: UploadOptions

    Returns Promise<Params>

  • Get HTTP header from message.

    Example

    // Get User-Agent header
    const agent = body.get('User-Agent');

    Parameters

    • name: string

    Returns null | string

  • Get HTML message body as @mojojs/dom object.

    Returns Promise<default>

  • Get JSON message body as parsed data structure.

    Type Parameters

    Returns Promise<T>

  • Pipe message body to writable stream.

    Parameters

    • writer: Writable

    Returns Promise<void>

  • Set HTTP header for message. // Set Server header body.set('Server', 'mojo.js');

    Parameters

    • name: string
    • value: string

    Returns UserAgentResponse

  • Get message body as string.

    Parameters

    • charset: BufferEncoding = 'utf8'

    Returns Promise<string>

  • Get XML message body as @mojojs/dom object.

    Returns Promise<default>

  • Get YAML message body as parsed data structure.

    Returns Promise<unknown>

Generated using TypeDoc