Request class
Whenever the page sends a request, such as for a network resource, the following events are emitted by puppeteer's page:
onRequestemitted when the request is issued by the page.onResponseemitted when/if the response is received for the request.onRequestFinishedemitted 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
Properties
- allowInterception → bool
-
final
- event → RequestWillBeSentEvent
-
final
- failure → String?
-
The method returns
nullunless this request was failed, as reported byonRequestFailedevent.no setter - frame → Frame?
-
A Frame that initiated this request, or
nullif 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
-
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
redirectChainis 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
nullif 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