Fake Mirrors
    Preparing search index...

    Class HttpMessage

    Complete HTTP message representation with request and response components.

    Supports both normal HTTP and WebSocket messages with interceptor pipelines.

    • Creates a new message instance.

      Parameters

      • type:
            | "normal-simple"
            | "normal-stream-request"
            | "normal-stream-response"
            | "websocket"

        The message type.

      Returns HttpMessage

    analyze: string = 'default'

    Name of the analyze queue job.

    connection: HttpConnection = {}

    Connection details for this message.

    errors: HttpError[] = []

    Accumulated errors during processing.

    id: string = ...

    Unique identifier for this message.

    Request method wrapper.

    payload: HttpPayload = {}

    Payload data for this message.

    requestBody: HttpBodyWrap

    Request body wrapper.

    requestHeaders: HttpHeadersWrap

    Request headers wrapper.

    responseBody: HttpBodyWrap

    Response body wrapper.

    responseHeaders: HttpHeadersWrap

    Response headers wrapper.

    Response status wrapper.

    Request URL wrapper.

    • get isReady(): boolean

      Checks if the message is ready for processing.

      Returns boolean

      true if the message is ready, false otherwise.

    • get type(): | "normal-simple"
      | "normal-stream-request"
      | "normal-stream-response"
      | "websocket"

      Gets the message type.

      Returns
          | "normal-simple"
          | "normal-stream-request"
          | "normal-stream-response"
          | "websocket"

      The current message type.

    • Registers MIME types for a content-type category.

      Parameters

      • name: "text" | "json" | "html" | "css" | "javascript" | "xml" | "urlEncoded"

        The content-type category name.

      • types: string[]

        The array of MIME types to register.

      Returns this

      This message for method chaining.

      Error If the message is already ready.

    • Adds an error with a path context.

      Parameters

      • error: unknown

        The error object or unknown value.

      • path: string[]

        The path segments indicating where the error occurred.

      Returns this

      This message for method chaining.

    • Adds a request body interceptor.

      Request body interceptors are called after the request head interceptors.

      Parameters

      Returns this

      This message for method chaining.

      Error If the message is already ready.

    • Adds a request head interceptor.

      Request head interceptors are called before the request body is processed.

      Parameters

      Returns this

      This message for method chaining.

      Error If the message is already ready.

    • Adds a stream transform for the request body.

      Parameters

      • transform: Transform

        The transform stream to add.

      Returns this

      This message for method chaining.

      Error If the message is already ready.

    • Adds a response body interceptor.

      Response body interceptors are called after the response head interceptors.

      Parameters

      Returns this

      This message for method chaining.

      Error If the message is already ready.

    • Adds a response head interceptor.

      Response head interceptors are called before the response body is processed.

      Parameters

      Returns this

      This message for method chaining.

      Error If the message is already ready.

    • Adds a stream transform for the response body.

      Parameters

      • transform: Transform

        The transform stream to add.

      Returns this

      This message for method chaining.

      Error If the message is already ready.

    • Adds content-types eligible for URL rewriting.

      Parameters

      • types: string[]

        The array of MIME types to add.

      Returns this

      This message for method chaining.

      Error If the message is already ready.

    • Adds extra URL rewriting schemes for percent and unicode encoded URLs.

      Returns this

      This message for method chaining.

      Error If the message is already ready.

    • Decocrates request body as HTML.

      Parameters

      • cb: ($: CheerioAPI) => void

      Returns void

    • Decorates request body as JSON.

      Parameters

      Returns void

    • Decorates request body as Query String.

      Parameters

      Returns void

    • Decorates request body as plain text.

      Parameters

      • cb: (text: string) => string

      Returns void

    • Decorate request body as XML.

      Parameters

      • cb: ($: CheerioAPI) => void

      Returns void

    • Decocrates response body as HTML.

      Parameters

      • cb: ($: CheerioAPI) => void

      Returns void

    • Decorates response body as JSON.

      Parameters

      Returns void

    • Decorates response body as Query String.

      Parameters

      Returns void

    • Decorates response body as plain text.

      Parameters

      • cb: (text: string) => string

      Returns void

    • Decorate response body as XML.

      Parameters

      • cb: ($: CheerioAPI) => void

      Returns void

    • Gets the request transforms.

      Returns Transform[]

      The array of transforms.

    • Gets the response transforms.

      Returns Transform[]

      The array of transforms.

    • Checks if a string is an absolute URL.

      Parameters

      • value: string

        The URL string to check.

      Returns boolean

      true if it's an absolute URL, false otherwise.

    • Checks if a request content-type belongs to a category.

      Parameters

      • name: "text" | "json" | "html" | "css" | "javascript" | "xml" | "urlEncoded"

        The content-type category name.

      Returns boolean

      true if the content-type matches the category, false otherwise.

    • Checks if a response content-type belongs to a category.

      Parameters

      • name: "text" | "json" | "html" | "css" | "javascript" | "xml" | "urlEncoded"

        The content-type category name.

      Returns boolean

      true if the content-type matches the category, false otherwise.

    • Checks if a content-type supports URL rewriting.

      Parameters

      Returns boolean

      true if rewriting is applicable, false otherwise.

    • Merges connection details into the message.

      Parameters

      Returns this

      This message for method chaining.

    • Marks the message as ready for processing.

      After this call, the message structure or content cannot be modified.

      Returns this

      This message for method chaining.

    • Retrieves request body as HTML.

      Returns CheerioAPI | null

    • Retrieves request body as JSON.

      Returns HttpJson

    • Retrieves request body as plain text.

      Returns string | null

    • Retrieves request body as XML.

      Returns CheerioAPI | null

    • Retrieves response body as HTML.

      Returns CheerioAPI | null

    • Retrieves response body as JSON.

      Returns HttpJson

    • Retrieves response body as plain text.

      Returns string | null

    • Retrieves response body as XML.

      Returns CheerioAPI | null

    • Rewrites URLs in text content.

      Parameters

      • text: string

        The text content containing URLs.

      • rev: boolean

        If false, replaces donor to mirror; if true, replaces mirror to donor.

      • targets: RewriteUrlTarget[]

        The URL rewrite targets.

      Returns string

      The text with rewritten URLs.

    • Runs all registered request body interceptors in order.

      This method freezes the request headers and body after execution.

      Returns this

      This message for method chaining.

      Error If the message is not ready.

    • Runs all registered request head interceptors in order.

      This method freezes the method and URL after execution.

      Returns this

      This message for method chaining.

      Error If the message is not ready.

    • Runs all registered response body interceptors in order.

      This method freezes the response headers and body after execution.

      Returns this

      This message for method chaining.

      Error If the message is not ready.

    • Runs all registered response head interceptors in order.

      This method freezes the status after execution.

      Returns this

      This message for method chaining.

      Error If the message is not ready.

    • Sets the message type with validation.

      The type can only be changed to a compatible type based on the current type.

      Parameters

      • type:
            | "normal-simple"
            | "normal-stream-request"
            | "normal-stream-response"
            | "websocket"

        The new message type.

      Returns this

      This message for method chaining.

      Error If the message is already ready.

      Error If the type transition is invalid.

    • Factory method to create a message by type.

      Parameters

      • type: string

        The message type.

      Returns HttpMessage

      A new message instance.

      Error If the message type is unknown.