Fake Mirrors
    Preparing search index...

    Class HttpBodyWrap

    Wrapper class for HTTP message bodies.

    formatQueryStringOptions: IStringifyBaseOptions = {}

    Custom options for formatting query strings.

    parseQueryStringOptions: IParseBaseOptions = {}

    Custom options for parsing query strings.

    • get isFrozen(): boolean

      Checks if the wrapper is frozen (read-only).

      Returns boolean

      true if the wrapper is frozen, false otherwise.

    • get length(): number

      Gets the body buffer size in bytes.

      Returns number

      The size of the body.

    • Clones the wrapper with a copy of the body.

      Returns HttpBodyWrap

      A new independent wrapper instance.

    • Freezes the wrapper to prevent modifications.

      Returns this

      This wrapper for method chaining.

    • Gets the raw body buffer.

      Returns HttpBody

      The Buffer containing the body.

    • Gets the body as a Base64 string (cached).

      Returns string

      The Base64 encoded body.

      Error If Base64 encoding fails.

    • Gets the body as a JSON object (cached).

      Parameters

      • Optionalcharset: string

        The optional character encoding.

      Returns HttpJson

      The parsed JSON object.

      Error If decoding or JSON parsing fails.

    • Gets the body as a query string object (cached).

      Parameters

      • Optionalcharset: string

        The optional character encoding.

      Returns HttpQueryString

      The parsed query string object.

      Error If parsing fails.

    • Gets the body as a text string (cached).

      Parameters

      • charset: string = 'utf8'

        The character encoding, default: 'utf8'.

      Returns string

      The decoded text.

      Error If decoding fails.

    • Clears the body and resets all caches.

      Returns this

      This wrapper for method chaining.

      Error If the wrapper is frozen.

    • Sets the raw body buffer.

      Parameters

      • body: HttpBody

        The Buffer to set as the body.

      Returns this

      This wrapper for method chaining.

      Error If the wrapper is frozen.

    • Sets the body from a Base64 string.

      Parameters

      • base64: string

        The Base64 encoded string.

      Returns this

      This wrapper for method chaining.

      Error If the wrapper is frozen.

      Error If Base64 decoding fails.

    • Sets the body from a JSON object.

      Parameters

      • json: HttpJson

        The JSON object to stringify.

      • Optionalcharset: string

        The optional character encoding.

      Returns this

      This wrapper for method chaining.

      Error If the wrapper is frozen.

      Error If JSON stringification or encoding fails.

    • Sets the body from a query string object.

      Parameters

      • queryString: HttpQueryString

        The query string object.

      • Optionalcharset: string

        The optional character encoding.

      Returns this

      This wrapper for method chaining.

      Error If the wrapper is frozen.

      Error If formatting fails.

    • Sets the body from a text string.

      Parameters

      • text: string

        The text to set as the body.

      • charset: string = 'utf8'

        The character encoding, default: 'utf8'.

      Returns this

      This wrapper for method chaining.

      Error If the wrapper is frozen.

      Error If encoding fails.

    • Factory method to create a wrapper from scratch.

      Returns HttpBodyWrap

      A new wrapper instance with an empty body.