ThemeParks.wiki Parks API - v2.0.0
    Preparing search index...

    Type Alias HttpTransport

    HttpTransport: (
        request: HttpRequestOptions,
        caller: HttpCaller,
        send: (request: HttpRequestOptions) => Promise<Response>,
    ) => Promise<Response>

    A function between the @http queue and the network. It receives the request as it is about to go out (after the injectors, with the default user-agent and accept-encoding filled in and the body encoded as it is sent), who makes it, and send, which performs the real request. It may call send (as is, or with a changed request) or return a Response of its own without touching the network. Whatever send throws (a timeout, a connection error) passes through unless the transport catches it.

    Of the errors a transport lets through, only one that send rejected with is retried, as a failed connection is, and only when the transport rethrows it as is. Any other error the transport throws is its own, whether before send (a replay without a recording) or after it (a recorder whose disk is full), and fails the request at once without a retry, so a park that has already answered is not asked again. A missing or already read Response fails the same way. The caller receives an HttpTransportError, and a request whose injector lets one through from a nested request fails without a retry as well.

    Rules for a transport:

    • Read a body only from response.clone(). The Response it returns must be unread, because parksapi reads it afterwards.
    • The request carries secrets: auth headers, proxy keys and forwarded headers in the URL, proxyUrl, an mTLS key, the credentials in the body of a sign-in, whose response carries a token. caller.args can carry credentials too. Redact a copy before storing anything. redactUrlSecrets(request.url) masks what the URL carries of them: the proxy keys, the forwarded headers and the credential query parameters.
    • What it returns is cached like a network response when the method caches.
    • The timeout applies inside send only. A request from the queue holds its slot in the concurrency limit while the transport runs, so the transport must end on its own, must not call an @http method itself, and should not take longer than the request it replaces.

    Type Declaration