Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface ResolvableRequest

Hierarchy

  • HTTPRequest
    • ResolvableRequest

Index

Properties

_failureText

_failureText: null | string
internal

_fromMemoryCache

_fromMemoryCache: boolean
internal

_interceptionId

_interceptionId: undefined | string
internal

_redirectChain

_redirectChain: HTTPRequest[]
internal

_requestId

_requestId: string
internal

_response

_response: null | HTTPResponse
internal

isResolved

isResolved: boolean

resolver

resolver: () => void

Type declaration

    • (): void
    • Returns void

Methods

abort

  • abort(errorCode?: "aborted" | "accessdenied" | "addressunreachable" | "blockedbyclient" | "blockedbyresponse" | "connectionaborted" | "connectionclosed" | "connectionfailed" | "connectionrefused" | "connectionreset" | "internetdisconnected" | "namenotresolved" | "timedout" | "failed", priority?: number): Promise<void>
  • Aborts a request.

    remarks

    To use this, request interception should be enabled with Page.setRequestInterception. If it is not enabled, this method will throw an exception immediately.

    Parameters

    • Optional errorCode: "aborted" | "accessdenied" | "addressunreachable" | "blockedbyclient" | "blockedbyresponse" | "connectionaborted" | "connectionclosed" | "connectionfailed" | "connectionrefused" | "connectionreset" | "internetdisconnected" | "namenotresolved" | "timedout" | "failed"

      optional error code to provide.

    • Optional priority: number

      If provided, intercept is resolved using cooperative handling rules. Otherwise, intercept is resolved immediately.

    Returns Promise<void>

abortErrorReason

  • abortErrorReason(): null | "Failed" | "Aborted" | "TimedOut" | "AccessDenied" | "ConnectionClosed" | "ConnectionReset" | "ConnectionRefused" | "ConnectionAborted" | "ConnectionFailed" | "NameNotResolved" | "InternetDisconnected" | "AddressUnreachable" | "BlockedByClient" | "BlockedByResponse"
  • Returns null | "Failed" | "Aborted" | "TimedOut" | "AccessDenied" | "ConnectionClosed" | "ConnectionReset" | "ConnectionRefused" | "ConnectionAborted" | "ConnectionFailed" | "NameNotResolved" | "InternetDisconnected" | "AddressUnreachable" | "BlockedByClient" | "BlockedByResponse"

    the most recent reason for aborting the request

continue

  • continue(overrides?: ContinueRequestOverrides, priority?: number): Promise<void>
  • Continues request with optional request overrides.

    remarks

    To use this, request interception should be enabled with Page.setRequestInterception.

    Exception is immediately thrown if the request interception is not enabled.

    example
    await page.setRequestInterception(true);
    page.on('request', request => {
      // Override headers
      const headers = Object.assign({}, request.headers(), {
        foo: 'bar', // set "foo" header
        origin: undefined, // remove "origin" header
      });
      request.continue({headers});
    });
    

    Parameters

    • Optional overrides: ContinueRequestOverrides

      optional overrides to apply to the request.

    • Optional priority: number

      If provided, intercept is resolved using cooperative handling rules. Otherwise, intercept is resolved immediately.

    Returns Promise<void>

continueRequestOverrides

  • continueRequestOverrides(): ContinueRequestOverrides
  • Returns ContinueRequestOverrides

    the ContinueRequestOverrides that will be used if the interception is allowed to continue (ie, abort() and respond() aren't called).

enqueueInterceptAction

  • enqueueInterceptAction(pendingHandler: () => void | PromiseLike<unknown>): void
  • Adds an async request handler to the processing queue. Deferred handlers are not guaranteed to execute in any particular order, but they are guaranteed to resolve before the request interception is finalized.

    Parameters

    • pendingHandler: () => void | PromiseLike<unknown>
        • (): void | PromiseLike<unknown>
        • Returns void | PromiseLike<unknown>

    Returns void

failure

  • failure(): null | { errorText: string }
  • Access information about the request's failure.

    remarks
    example

    Example of logging all failed requests:

    page.on('requestfailed', request => {
      console.log(request.url() + ' ' + request.failure().errorText);
    });
    

    Returns null | { errorText: string }

    null unless the request failed. If the request fails this can return an object with errorText containing a human-readable error message, e.g. net::ERR_FAILED. It is not guaranteed that there will be failure text if the request fails.

finalizeInterceptions

  • finalizeInterceptions(): Promise<void>
  • Awaits pending interception handlers and then decides how to fulfill the request interception.

    Returns Promise<void>

frame

  • frame(): null | Frame
  • Returns null | Frame

    the frame that initiated the request, or null if navigating to error pages.

headers

  • headers(): Record<string, string>
  • Returns Record<string, string>

    an object with HTTP headers associated with the request. All header names are lower-case.

initiator

  • initiator(): Initiator
  • Returns Initiator

    the initiator of the request.

interceptResolutionState

  • interceptResolutionState(): InterceptResolutionState
  • Returns InterceptResolutionState

    An InterceptResolutionState object describing the current resolution action and priority.

    InterceptResolutionState contains: action: InterceptResolutionAction priority?: number

    InterceptResolutionAction is one of: abort, respond, continue, disabled, none, or already-handled.

isInterceptResolutionHandled

  • isInterceptResolutionHandled(): boolean
  • Returns boolean

    true if the intercept resolution has already been handled, false otherwise.

isNavigationRequest

  • isNavigationRequest(): boolean
  • Returns boolean

    true if the request is the driver of the current frame's navigation.

method

  • method(): string
  • Returns string

    the method used (GET, POST, etc.)

postData

  • postData(): undefined | string
  • Returns undefined | string

    the request's post body, if any.

redirectChain

  • redirectChain(): HTTPRequest[]
  • A redirectChain is a chain of requests initiated to fetch a resource.

    remarks

    redirectChain is shared between all the requests of the same chain.

    For example, if the website http://example.com has a single redirect to https://example.com, then the chain will contain one request:

    const response = await page.goto('http://example.com');
    const chain = response.request().redirectChain();
    console.log(chain.length); // 1
    console.log(chain[0].url()); // 'http://example.com'
    

    If the website https://google.com has no redirects, then the chain will be empty:

    const response = await page.goto('https://google.com');
    const chain = response.request().redirectChain();
    console.log(chain.length); // 0
    

    Returns HTTPRequest[]

    the chain of requests - if a server responds with at least a single redirect, this chain will contain all requests that were redirected.

resourceType

  • resourceType(): "document" | "stylesheet" | "image" | "media" | "font" | "script" | "texttrack" | "xhr" | "fetch" | "eventsource" | "websocket" | "manifest" | "other" | "signedexchange" | "ping" | "cspviolationreport" | "preflight"
  • Contains the request's resource type as it was perceived by the rendering engine.

    Returns "document" | "stylesheet" | "image" | "media" | "font" | "script" | "texttrack" | "xhr" | "fetch" | "eventsource" | "websocket" | "manifest" | "other" | "signedexchange" | "ping" | "cspviolationreport" | "preflight"

respond

  • respond(response: Partial<ResponseForRequest>, priority?: number): Promise<void>
  • Fulfills a request with the given response.

    remarks

    To use this, request interception should be enabled with Page.setRequestInterception.

    Exception is immediately thrown if the request interception is not enabled.

    example

    An example of fulfilling all requests with 404 responses:

    await page.setRequestInterception(true);
    page.on('request', request => {
      request.respond({
        status: 404,
        contentType: 'text/plain',
        body: 'Not Found!'
      });
    });
    

    NOTE: Mocking responses for dataURL requests is not supported. Calling request.respond for a dataURL request is a noop.

    Parameters

    • response: Partial<ResponseForRequest>

      the response to fulfill the request with.

    • Optional priority: number

      If provided, intercept is resolved using cooperative handling rules. Otherwise, intercept is resolved immediately.

    Returns Promise<void>

response

  • response(): null | HTTPResponse
  • Returns null | HTTPResponse

    A matching HTTPResponse object, or null if the response has not been received yet.

responseForRequest

  • responseForRequest(): null | Partial<ResponseForRequest>
  • Returns null | Partial<ResponseForRequest>

    The ResponseForRequest that gets used if the interception is allowed to respond (ie, abort() is not called).

url

  • url(): string
  • Returns string

    the URL of the request

Generated using TypeDoc