protocol/fetch
⚙️ This module was generated from the Chrome DevTools Protocol version 1.3
Fetch Domain
A domain for letting clients substitute browser’s network layer with client code.
📖 View this domain on the DevTools Protocol API Docs
Types
Authorization challenge for HTTP status code 401 or 407.
pub type AuthChallenge {
AuthChallenge(
source: option.Option(AuthChallengeSource),
origin: String,
scheme: String,
realm: String,
)
}
Constructors
-
AuthChallenge( source: option.Option(AuthChallengeSource), origin: String, scheme: String, realm: String, )
Arguments
-
source
Source of the authentication challenge.
-
origin
Origin of the challenger.
-
scheme
The authentication scheme used, such as basic or digest
-
realm
The realm of the challenge. May be empty.
-
Response to an AuthChallenge.
pub type AuthChallengeResponse {
AuthChallengeResponse(
response: AuthChallengeResponseResponse,
username: option.Option(String),
password: option.Option(String),
)
}
Constructors
-
AuthChallengeResponse( response: AuthChallengeResponseResponse, username: option.Option(String), password: option.Option(String), )
Arguments
-
response
The decision on what to do in response to the authorization challenge. Default means deferring to the default behavior of the net stack, which will likely either the Cancel authentication or display a popup dialog box.
-
username
The username to provide, possibly empty. Should only be set if response is ProvideCredentials.
-
password
The password to provide, possibly empty. Should only be set if response is ProvideCredentials.
-
This type is not part of the protocol spec, it has been generated dynamically
to represent the possible values of the enum property response
of AuthChallengeResponse
pub type AuthChallengeResponseResponse {
AuthChallengeResponseResponseDefault
AuthChallengeResponseResponseCancelAuth
AuthChallengeResponseResponseProvideCredentials
}
Constructors
-
AuthChallengeResponseResponseDefault
-
AuthChallengeResponseResponseCancelAuth
-
AuthChallengeResponseResponseProvideCredentials
This type is not part of the protocol spec, it has been generated dynamically
to represent the possible values of the enum property source
of AuthChallenge
pub type AuthChallengeSource {
AuthChallengeSourceServer
AuthChallengeSourceProxy
}
Constructors
-
AuthChallengeSourceServer
-
AuthChallengeSourceProxy
This type is not part of the protocol spec, it has been generated dynamically
to represent the response to the command get_response_body
pub type GetResponseBodyResponse {
GetResponseBodyResponse(body: String, base64_encoded: Bool)
}
Constructors
-
GetResponseBodyResponse(body: String, base64_encoded: Bool)
Arguments
-
body
Response body.
-
base64_encoded
True, if content was sent as base64.
-
Response HTTP header entry
pub type HeaderEntry {
HeaderEntry(name: String, value: String)
}
Constructors
-
HeaderEntry(name: String, value: String)
Unique request identifier.
pub type RequestId {
RequestId(String)
}
Constructors
-
RequestId(String)
pub type RequestPattern {
RequestPattern(
url_pattern: option.Option(String),
resource_type: option.Option(network.ResourceType),
request_stage: option.Option(RequestStage),
)
}
Constructors
-
RequestPattern( url_pattern: option.Option(String), resource_type: option.Option(network.ResourceType), request_stage: option.Option(RequestStage), )
Arguments
-
url_pattern
Wildcards (
'*'
-> zero or more,'?'
-> exactly one) are allowed. Escape character is backslash. Omitting is equivalent to"*"
. -
resource_type
If set, only requests for matching resource types will be intercepted.
-
request_stage
Stage at which to begin intercepting requests. Default is Request.
-
Stages of the request to handle. Request will intercept before the request is sent. Response will intercept after the response is received (but before response body is received).
pub type RequestStage {
RequestStageRequest
RequestStageResponse
}
Constructors
-
RequestStageRequest
-
RequestStageResponse
This type is not part of the protocol spec, it has been generated dynamically
to represent the response to the command take_response_body_as_stream
pub type TakeResponseBodyAsStreamResponse {
TakeResponseBodyAsStreamResponse(stream: io.StreamHandle)
}
Constructors
-
TakeResponseBodyAsStreamResponse(stream: io.StreamHandle)
Functions
pub fn continue_request(
callback__: fn(String, Option(Json)) -> a,
request_id request_id: RequestId,
url url: Option(String),
method method: Option(String),
post_data post_data: Option(String),
headers headers: Option(List(HeaderEntry)),
) -> a
Continues the request, optionally modifying some of its parameters.
Parameters:
request_id
: 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.post_data
: If set, overrides the post data in the request. (Encoded as a base64 string when passed over JSON)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.
Returns:
pub fn continue_with_auth(
callback__: fn(String, Option(Json)) -> a,
request_id request_id: RequestId,
auth_challenge_response auth_challenge_response: AuthChallengeResponse,
) -> a
Continues a request supplying authChallengeResponse following authRequired event.
Parameters:
request_id
: An id the client received in authRequired event.auth_challenge_response
: Response to with an authChallenge.
Returns:
pub fn enable(
callback__: fn(String, Option(Json)) -> a,
patterns patterns: Option(List(RequestPattern)),
handle_auth_requests handle_auth_requests: Option(Bool),
) -> a
Enables issuing of requestPaused events. A request will be paused until client calls one of failRequest, fulfillRequest or continueRequest/continueWithAuth.
Parameters:
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.handle_auth_requests
: If true, authRequired events will be issued and requests will be paused expecting a call to continueWithAuth.
Returns:
pub fn fail_request(
callback__: fn(String, Option(Json)) -> a,
request_id request_id: RequestId,
error_reason error_reason: ErrorReason,
) -> a
Causes the request to fail with specified reason.
Parameters:
request_id
: An id the client received in requestPaused event.error_reason
: Causes the request to fail with the given reason.
Returns:
pub fn fulfill_request(
callback__: fn(String, Option(Json)) -> a,
request_id request_id: RequestId,
response_code response_code: Int,
response_headers response_headers: Option(List(HeaderEntry)),
binary_response_headers binary_response_headers: Option(String),
body body: Option(String),
response_phrase response_phrase: Option(String),
) -> a
Provides response to the request.
Parameters:
request_id
: An id the client received in requestPaused event.response_code
: An HTTP response code.response_headers
: Response headers.binary_response_headers
: 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. (Encoded as a base64 string when passed over JSON)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. (Encoded as a base64 string when passed over JSON)response_phrase
: A textual representation of responseCode. If absent, a standard phrase matching responseCode is used.
Returns:
pub fn get_response_body(
callback__: fn(String, Option(Json)) ->
Result(Dynamic, RequestError),
request_id request_id: RequestId,
) -> Result(GetResponseBodyResponse, RequestError)
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.
Note that the response body is not available for redirects. Requests
paused in the redirect received state may be differentiated by
responseCode
and presence of location
response header, see
comments to requestPaused
for details.
Parameters:
request_id
: Identifier for the intercepted request to get body for.
Returns:
body
: Response body.base64_encoded
: True, if content was sent as base64.
pub fn take_response_body_as_stream(
callback__: fn(String, Option(Json)) ->
Result(Dynamic, RequestError),
request_id request_id: RequestId,
) -> Result(TakeResponseBodyAsStreamResponse, RequestError)
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.
Parameters:
request_id
Returns:
stream