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 | null = null

    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 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 void

      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 void

    • Adds a request body interceptor.

      Request body interceptors are called after the request head interceptors.

      Parameters

      Returns void

      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 void

      Error If the message is already ready.

    • Adds a stream transform for the request body.

      Parameters

      • transform: Transform

        The transform stream to add.

      Returns void

      Error If the message is already ready.

    • Adds a response body interceptor.

      Response body interceptors are called after the response head interceptors.

      Parameters

      Returns void

      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 void

      Error If the message is already ready.

    • Adds a stream transform for the response body.

      Parameters

      • transform: Transform

        The transform stream to add.

      Returns void

      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 void

      Error If the message is already ready.

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

      Returns void

      Error If the message is already ready.

    • 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 content-type belongs to a category.

      Parameters

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

        The content-type category name.

      • contentType: HttpContentType

        The parsed content-type to check.

      Returns boolean

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

    • Marks the message as ready for processing.

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

      Returns void

    • 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 void

      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 void

      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 void

      Error If the message is not ready.

    • Runs all registered response head interceptors in order.

      This method freezes the status after execution.

      Returns void

      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 void

      Error If the message is already ready.

      Error If the type transition is invalid.