FetchApi class
A domain for letting clients substitute browser's network layer with client code.
Constructors
- FetchApi(Client _client)
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
-
onAuthRequired
→ Stream<
AuthRequiredEvent> -
Issued when the domain is enabled with handleAuthRequests set to true.
The request is paused until client responds with continueWithAuth.
no setter
-
onRequestPaused
→ Stream<
RequestPausedEvent> -
Issued when the domain is enabled and the request URL matches the
specified filter. The request is paused until the client responds
with one of continueRequest, failRequest or fulfillRequest.
The stage of the request can be determined by presence of responseErrorReason
and responseStatusCode -- the request is at the response stage if either
of these fields is present and in the request stage otherwise.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
continueRequest(
RequestId requestId, {String? url, String? method, String? postData, List< HeaderEntry> ? headers, bool? interceptResponse}) → Future<void> -
Continues the request, optionally modifying some of its parameters.
requestId
An id the client received in requestPaused event.url
If set, the request url will be modified in a way that's not observable by page.method
If set, the request method is overridden.postData
If set, overrides the post data in the request.headers
If set, overrides the request headers. Note that the overrides do not extend to subsequent redirect hops, if a redirect happens. Another override may be applied to a different request produced by a redirect.interceptResponse
If set, overrides response interception behavior for this request. -
continueResponse(
RequestId requestId, {int? responseCode, String? responsePhrase, List< HeaderEntry> ? responseHeaders, String? binaryResponseHeaders}) → Future<void> -
Continues loading of the paused response, optionally modifying the
response headers. If either responseCode or headers are modified, all of them
must be present.
requestId
An id the client received in requestPaused event.responseCode
An HTTP response code. If absent, original response code will be used.responsePhrase
A textual representation of responseCode. If absent, a standard phrase matching responseCode is used.responseHeaders
Response headers. If absent, original response headers will be used.binaryResponseHeaders
Alternative way of specifying response headers as a \0-separated series of name: value pairs. Prefer the above method unless you need to represent some non-UTF8 values that can't be transmitted over the protocol as text. -
continueWithAuth(
RequestId requestId, AuthChallengeResponse authChallengeResponse) → Future< void> -
Continues a request supplying authChallengeResponse following authRequired event.
requestId
An id the client received in authRequired event.authChallengeResponse
Response to with an authChallenge. -
disable(
) → Future< void> - Disables the fetch domain.
-
enable(
{List< RequestPattern> ? patterns, bool? handleAuthRequests}) → Future<void> -
Enables issuing of requestPaused events. A request will be paused until client
calls one of failRequest, fulfillRequest or continueRequest/continueWithAuth.
patterns
If specified, only requests matching any of these patterns will produce fetchRequested event and will be paused until clients response. If not set, all requests will be affected.handleAuthRequests
If true, authRequired events will be issued and requests will be paused expecting a call to continueWithAuth. -
failRequest(
RequestId requestId, ErrorReason errorReason) → Future< void> -
Causes the request to fail with specified reason.
requestId
An id the client received in requestPaused event.errorReason
Causes the request to fail with the given reason. -
fulfillRequest(
RequestId requestId, int responseCode, {List< HeaderEntry> ? responseHeaders, String? binaryResponseHeaders, String? body, String? responsePhrase}) → Future<void> -
Provides response to the request.
requestId
An id the client received in requestPaused event.responseCode
An HTTP response code.responseHeaders
Response headers.binaryResponseHeaders
Alternative way of specifying response headers as a \0-separated series of name: value pairs. Prefer the above method unless you need to represent some non-UTF8 values that can't be transmitted over the protocol as text.body
A response body. If absent, original response body will be used if the request is intercepted at the response stage and empty body will be used if the request is intercepted at the request stage.responsePhrase
A textual representation of responseCode. If absent, a standard phrase matching responseCode is used. -
getResponseBody(
RequestId requestId) → Future< GetResponseBodyResult> -
Causes the body of the response to be received from the server and
returned as a single string. May only be issued for a request that
is paused in the Response stage and is mutually exclusive with
takeResponseBodyForInterceptionAsStream. Calling other methods that
affect the request or disabling fetch domain before body is received
results in an undefined behavior.
requestId
Identifier for the intercepted request to get body for. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
takeResponseBodyAsStream(
RequestId requestId) → Future< StreamHandle> - Returns a handle to the stream representing the response body. The request must be paused in the HeadersReceived stage. Note that after this command the request can't be continued as is -- client either needs to cancel it or to provide the response body. The stream only supports sequential read, IO.read will fail if the position is specified. This method is mutually exclusive with getResponseBody. Calling other methods that affect the request or disabling fetch domain before body is received results in an undefined behavior.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited