puppeteer/docs/api/puppeteer.httprequest.md
jrandolf f07ad2c661
fix: update documentation on configuring puppeteer (#9150)
This PR updates the docs regarding configuring puppeteer. In addition,
some changes have been made to the documentation generator to show
default values on the documentation site.

Also fixes: https://github.com/puppeteer/puppeteer/pull/9144
2022-10-24 09:07:05 +02:00

8.8 KiB

sidebar_label
HTTPRequest

HTTPRequest class

Represents an HTTP request sent by a page.

Signature:

export declare class HTTPRequest

Remarks

Whenever the page sends a request, such as for a network resource, the following events are emitted by Puppeteer's page:

  • request: emitted when the request is issued by the page. - requestfinished - emitted when the response body is downloaded and the request is complete.

If request fails at some point, then instead of requestfinished event the requestfailed event is emitted.

All of these events provide an instance of HTTPRequest representing the request that occurred:

page.on('request', request => ...)

NOTE: HTTP Error responses, such as 404 or 503, are still successful responses from HTTP standpoint, so request will complete with requestfinished event.

If request gets a 'redirect' response, the request is successfully finished with the requestfinished event, and a new request is issued to a redirected url.

The constructor for this class is marked as internal. Third-party code should not call the constructor directly or create subclasses that extend the HTTPRequest class.

Properties

Property Modifiers Type Description
client readonly CDPSession Warning! Using this client can break Puppeteer. Use with caution.

Methods

Method Modifiers Description
abort(errorCode, priority) Aborts a request.
abortErrorReason()
continue(overrides, priority) Continues request with optional request overrides.
continueRequestOverrides()
enqueueInterceptAction(pendingHandler) 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.
failure() Access information about the request's failure.
finalizeInterceptions() Awaits pending interception handlers and then decides how to fulfill the request interception.
frame()
headers()
initiator()
interceptResolutionState()
isInterceptResolutionHandled()
isNavigationRequest()
method()
postData()
redirectChain() A redirectChain is a chain of requests initiated to fetch a resource.
resourceType() Contains the request's resource type as it was perceived by the rendering engine.
respond(response, priority) Fulfills a request with the given response.
response()
responseForRequest()
url()