Request class

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

  • onRequest emitted when the request is issued by the page.
  • onResponse emitted when/if the response is received for the request.
  • onRequestFinished emitted when the response body is downloaded and the request is complete.

If request fails at some point, then instead of 'onRequestFinished' event (and possibly instead of 'response' event), the onRequestFailed event is emitted.

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

Constructors

Request(FetchApi _fetchApi, Frame? frame, String? interceptionId, RequestWillBeSentEvent event, {required List<Request> redirectChain, required bool? allowInterception})

Properties

allowInterception bool
final
event RequestWillBeSentEvent
final
failure String?
The method returns null unless this request was failed, as reported by onRequestFailed event.
no setter
frame Frame?
A Frame that initiated this request, or null if navigating to error pages.
final
hashCode int
The hash code for this object.
no setterinherited
headers Map<String, String>
An object with HTTP headers associated with the request. All header names are lower-case.
no setter
interceptionId String?
final
isNavigationRequest bool
Whether this request is driving frame's navigation.
no setter
method String
Request's method (GET, POST, etc.)
no setter
postData String?
Request's post body, if any.
no setter
redirectChain List<Request>
A redirectChain is a chain of requests initiated to fetch a resource.
final
requestId String
no setter
resourceType ResourceType?
Contains the request's resource type as it was perceived by the rendering engine.
no setter
response Response?
A matching Response object, or null if the response has not been received yet.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
url String
URL of the request.
no setter

Methods

abort({ErrorReason? error}) Future<void>
Aborts request. To use this, request interception should be enabled with page.setRequestInterception. Exception is immediately thrown if the request interception is not enabled.
continueRequest({String? url, String? method, String? postData, Map<String, String>? headers}) Future<void>
Continues request with optional request overrides. To use this, request interception should be enabled with page.setRequestInterception. Exception is immediately thrown if the request interception is not enabled.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
respond({int? status, Map<String, String>? headers, String? contentType, dynamic body}) Future<void>
Fulfills request with given response. To use this, request interception should be enabled with page.setRequestInterception. Exception is thrown if request interception is not enabled.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited