Options
All
  • Public
  • Public/Protected
  • All
Menu

Class HttpUtils

Hierarchy

  • HttpUtils

Index

Methods

Static isResponseOk

  • isResponseOk(response: IncomingMessage): boolean
  • Returns true if the response status is between 200 and 399 inclusive.

    Parameters

    • response: IncomingMessage

      Response from the Node.js http module.

    Returns boolean

Static mergeHeaders

  • mergeHeaders(dst: IncomingHttpHeaders | OutgoingHttpHeaders, src: IncomingHttpHeaders | OutgoingHttpHeaders, overwrite?: boolean): IncomingHttpHeaders
  • Returns the result of merging the src headers into the initial dst headers.

    Parameters

    • dst: IncomingHttpHeaders | OutgoingHttpHeaders

      The initial set of headers.

    • src: IncomingHttpHeaders | OutgoingHttpHeaders

      The headers to be merged into the dst.

    • Default value overwrite: boolean = true

      If true, headers in the src will overwrite existing headers in the dst.

    Returns IncomingHttpHeaders

    A new object containing the results of the merge.

Static toBodyText

  • toBodyText(response: IncomingMessage): Promise<string>
  • Returns a Promise that resolves to the text data contained in the response body.

    Parameters

    • response: IncomingMessage

      Response from the Node.js http module.

    Returns Promise<string>

Static toBuffer

  • toBuffer(response: IncomingMessage): Promise<Buffer>
  • Returns a Promise that resolves to the raw data contained in the response body.

    Parameters

    • response: IncomingMessage

      Response from the Node.js http module.

    Returns Promise<Buffer>

Static toIncomingHttpHeaders

  • toIncomingHttpHeaders(headers: IncomingHttpHeaders | OutgoingHttpHeaders): IncomingHttpHeaders
  • Converts a set of headers, either incoming or outgoing, to the incoming format used by the http module in Node.js.

    Parameters

    • headers: IncomingHttpHeaders | OutgoingHttpHeaders

      Headers to be converted to the incoming format.

    Returns IncomingHttpHeaders

Generated using TypeDoc