Options
All
  • Public
  • Public/Protected
  • All
Menu

Tiny HTTP Response class.

Hierarchy

  • Response

Index

Constructors

constructor

  • new Response(req: ClientRequest, res: IncomingMessage): Response

Properties

Protected data

data: Buffer = ...

raw

raw: IncomingMessage = ...

stream

stream: PassThrough = ...

Here you could track stream data.

Accessors

headers

  • get headers(): IncomingHttpHeaders
  • Get response headers

    Returns IncomingHttpHeaders

isOk

  • get isOk(): boolean

request

statusCode

  • get statusCode(): number
  • Get response status code like 200, 204, 403, 401, 301, etc.

    Returns number

statusMessage

  • get statusMessage(): string
  • Get response status message

    Returns string

Methods

getContent

  • getContent(encoding?: BufferEncoding): string
  • Get response content with encoding support.

    Parameters

    • encoding: BufferEncoding = 'utf8'

      Encoding content type you want. Like hex, baseurl, etc.

    Returns string

getData

  • getData(): Buffer
  • Get buffer response data

    Returns Buffer

getJSON

  • getJSON<T>(): Promise<T>
  • Get response content with JSON.parse

    Type parameters

    • T

    Returns Promise<T>

onDownload

  • onDownload(cb: OnDownloadProgressCallback): void
  • Here you could track download progress.

    Parameters

    • cb: OnDownloadProgressCallback

      Callback function for download progress

    Returns void

Generated using TypeDoc