Interface InterceptableRequest

Represents an intercepted HTTP request which can be modified.

interface InterceptableRequest {
    body: RequestBody;
    closed: boolean;
    headers: HTTPHeaders;
    mediaType: MediaType;
    method: RequestMethod;
    responseType: ResponseType;
    subType: RequestSubType;
    type: RequestType;
    url: string;
    useCredentials: boolean;
    redirect(request): void;
    respondWith(response): void;
    waitUntil(fn): void;
    waitUntil(promise): void;
}

Hierarchy (view full)

Properties

The request's body.

closed: boolean

Whether the request is closed.

headers: HTTPHeaders

The request's HTTP headers.

mediaType: MediaType

The request's media type.

The request's HTTP method.

responseType: ResponseType

The request's response type.

The request's subtype.

The request's type.

url: string

The request's URL.

useCredentials: boolean

Whether the player is allowed to use credentials for cross-origin requests.

Methods

  • Replaces the original request with the provided request.

    Parameters

    Returns void

    Remarks


    - Invocation closes the request.
    - Invocation while the request is closed will throw an error.

  • Immediately respond with the provided response.

    Parameters

    Returns void

    Remarks


    - Invocation closes the request.
    - Invocation while the request is closed will throw an error.
    - The original request will not be performed.

  • Wait until the given callback is done before closing and executing this request.

    Returns void

    Remarks


    - The first argument of the callback is a done function, which must be called to resolve the callback.
    - Alternatively, the callback can return a PromiseLike.
    - Invocation of the done function closes the request.
    - Invocation while the request is closed will throw an error.

  • Wait until the given promise is resolved before closing and executing this request.

    Parameters

    Returns void

    Remarks


    - Resolution of the promise closes the request.
    - Invocation while the request is closed will throw an error.
    - This is equivalent to:

    request.waitUntil(function (done) {
    promise.then(function () {
    done();
    }).catch(function (error) {
    done(error);
    });
    })