Options
All
  • Public
  • Public/Protected
  • All
Menu

Class RedirectChain

The HTTP redirects followed during one connection or reconnection attempt.

Only 301, 302, 307 and 308 are followed. The Location may be a ws, wss, http or https URL, or relative to the redirected URL; http maps to ws and https to wss. The Location is checked as the Java client checks it: it must be a US-ASCII URI reference with a host and a port from 1 to 65535. A host that is not a name must be a dotted-decimal IPv4 address or an IPv6 literal without a zone, and the WHATWG URL parser must accept it. Its user information and fragment are ignored. Its path and query are kept, except that an empty path or / becomes /diffusion.

At most MAX_REDIRECTS redirects are followed, a URL may not repeat, and a secure connection is never redirected to an insecure one.

Hierarchy

  • RedirectChain

Index

Constructors

Properties

Methods

Constructors

constructor

  • Create a new RedirectChain instance

    Parameters

    • origin: WebSocketTarget

      the URL the connection attempt starts from, without the client's own query parameters

    Returns RedirectChain

Properties

Private current

The URL most recently connected to

Private Readonly visited

visited: string[]

The URLs connected to, as loop detection compares them

Methods

follow

  • follow(status: number, location?: undefined | string): string
  • Validates a redirect of the URL most recently connected to and returns the URL to connect to next.

    throws

    an Error naming the redirect and why it was rejected if the status is not followed, the Location is missing or invalid, the redirect would downgrade a secure connection, the redirect limit is exceeded or the URL has already been visited

    Parameters

    • status: number

      the HTTP status of the redirect response

    • Optional location: undefined | string

      the redirect response's Location header, if any

    Returns string

    the redirect URL, with the Location's query but without the client's own query parameters

Copyright © 2025 DiffusionData Ltd. All Rights Reserved.