Documentation ¶
Overview ¶
Package fetch implements the Fetch domain. A domain for letting clients substitute browser's network layer with client code.
Index ¶
- func NewClient(conn *rpcc.Conn) *domainClient
- type AuthChallenge
- type AuthChallengeResponse
- type AuthRequiredClient
- type AuthRequiredReply
- type ContinueRequestArgs
- func (a *ContinueRequestArgs) SetHeaders(headers []HeaderEntry) *ContinueRequestArgs
- func (a *ContinueRequestArgs) SetMethod(method string) *ContinueRequestArgs
- func (a *ContinueRequestArgs) SetPostData(postData []byte) *ContinueRequestArgs
- func (a *ContinueRequestArgs) SetURL(url string) *ContinueRequestArgs
- type ContinueWithAuthArgs
- type EnableArgs
- type FailRequestArgs
- type FulfillRequestArgs
- func (a *FulfillRequestArgs) SetBinaryResponseHeaders(binaryResponseHeaders []byte) *FulfillRequestArgs
- func (a *FulfillRequestArgs) SetBody(body []byte) *FulfillRequestArgs
- func (a *FulfillRequestArgs) SetResponseHeaders(responseHeaders []HeaderEntry) *FulfillRequestArgs
- func (a *FulfillRequestArgs) SetResponsePhrase(responsePhrase string) *FulfillRequestArgs
- type GetResponseBodyArgs
- type GetResponseBodyReply
- type HeaderEntry
- type RequestID
- type RequestPattern
- type RequestPausedClient
- type RequestPausedReply
- type RequestStage
- type TakeResponseBodyAsStreamArgs
- type TakeResponseBodyAsStreamReply
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AuthChallenge ¶
type AuthChallenge struct { // Source Source of the authentication challenge. // // Values: "Server", "Proxy". Source *string `json:"source,omitempty"` Origin string `json:"origin"` // Origin of the challenger. Scheme string `json:"scheme"` // The authentication scheme used, such as basic or digest Realm string `json:"realm"` // The realm of the challenge. May be empty. }
AuthChallenge Authorization challenge for HTTP status code 401 or 407.
type AuthChallengeResponse ¶
type AuthChallengeResponse struct { // 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. // // Values: "Default", "CancelAuth", "ProvideCredentials". Response string `json:"response"` Username *string `json:"username,omitempty"` // The username to provide, possibly empty. Should only be set if response is ProvideCredentials. Password *string `json:"password,omitempty"` // The password to provide, possibly empty. Should only be set if response is ProvideCredentials. }
AuthChallengeResponse Response to an AuthChallenge.
type AuthRequiredClient ¶
type AuthRequiredClient interface { // Recv calls RecvMsg on rpcc.Stream, blocks until the event is // triggered, context canceled or connection closed. Recv() (*AuthRequiredReply, error) rpcc.Stream }
AuthRequiredClient is a client for AuthRequired events. Issued when the domain is enabled with handleAuthRequests set to true. The request is paused until client responds with continueWithAuth.
type AuthRequiredReply ¶
type AuthRequiredReply struct { RequestID RequestID `json:"requestId"` // Each request the page makes will have a unique id. Request network.Request `json:"request"` // The details of the request. FrameID page.FrameID `json:"frameId"` // The id of the frame that initiated the request. ResourceType network.ResourceType `json:"resourceType"` // How the requested resource will be used. AuthChallenge AuthChallenge `json:"authChallenge"` // Details of the Authorization Challenge encountered. If this is set, client should respond with continueRequest that contains AuthChallengeResponse. }
AuthRequiredReply is the reply for AuthRequired events.
type ContinueRequestArgs ¶
type ContinueRequestArgs struct { RequestID RequestID `json:"requestId"` // An id the client received in requestPaused event. URL *string `json:"url,omitempty"` // If set, the request url will be modified in a way that's not observable by page. Method *string `json:"method,omitempty"` // If set, the request method is overridden. PostData []byte `json:"postData,omitempty"` // If set, overrides the post data in the request. (Encoded as a base64 string when passed over JSON) Headers []HeaderEntry `json:"headers,omitempty"` // If set, overrides the request headers. }
ContinueRequestArgs represents the arguments for ContinueRequest in the Fetch domain.
func NewContinueRequestArgs ¶
func NewContinueRequestArgs(requestID RequestID) *ContinueRequestArgs
NewContinueRequestArgs initializes ContinueRequestArgs with the required arguments.
func (*ContinueRequestArgs) SetHeaders ¶
func (a *ContinueRequestArgs) SetHeaders(headers []HeaderEntry) *ContinueRequestArgs
SetHeaders sets the Headers optional argument. If set, overrides the request headers.
func (*ContinueRequestArgs) SetMethod ¶
func (a *ContinueRequestArgs) SetMethod(method string) *ContinueRequestArgs
SetMethod sets the Method optional argument. If set, the request method is overridden.
func (*ContinueRequestArgs) SetPostData ¶
func (a *ContinueRequestArgs) SetPostData(postData []byte) *ContinueRequestArgs
SetPostData sets the PostData optional argument. If set, overrides the post data in the request. (Encoded as a base64 string when passed over JSON)
func (*ContinueRequestArgs) SetURL ¶
func (a *ContinueRequestArgs) SetURL(url string) *ContinueRequestArgs
SetURL sets the URL optional argument. If set, the request url will be modified in a way that's not observable by page.
type ContinueWithAuthArgs ¶
type ContinueWithAuthArgs struct { RequestID RequestID `json:"requestId"` // An id the client received in authRequired event. AuthChallengeResponse AuthChallengeResponse `json:"authChallengeResponse"` // Response to with an authChallenge. }
ContinueWithAuthArgs represents the arguments for ContinueWithAuth in the Fetch domain.
func NewContinueWithAuthArgs ¶
func NewContinueWithAuthArgs(requestID RequestID, authChallengeResponse AuthChallengeResponse) *ContinueWithAuthArgs
NewContinueWithAuthArgs initializes ContinueWithAuthArgs with the required arguments.
type EnableArgs ¶
type EnableArgs struct { Patterns []RequestPattern `json:"patterns,omitempty"` // 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 *bool `json:"handleAuthRequests,omitempty"` // If true, authRequired events will be issued and requests will be paused expecting a call to continueWithAuth. }
EnableArgs represents the arguments for Enable in the Fetch domain.
func NewEnableArgs ¶
func NewEnableArgs() *EnableArgs
NewEnableArgs initializes EnableArgs with the required arguments.
func (*EnableArgs) SetHandleAuthRequests ¶
func (a *EnableArgs) SetHandleAuthRequests(handleAuthRequests bool) *EnableArgs
SetHandleAuthRequests sets the HandleAuthRequests optional argument. If true, authRequired events will be issued and requests will be paused expecting a call to continueWithAuth.
func (*EnableArgs) SetPatterns ¶
func (a *EnableArgs) SetPatterns(patterns []RequestPattern) *EnableArgs
SetPatterns sets the Patterns optional argument. 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.
type FailRequestArgs ¶
type FailRequestArgs struct { RequestID RequestID `json:"requestId"` // An id the client received in requestPaused event. ErrorReason network.ErrorReason `json:"errorReason"` // Causes the request to fail with the given reason. }
FailRequestArgs represents the arguments for FailRequest in the Fetch domain.
func NewFailRequestArgs ¶
func NewFailRequestArgs(requestID RequestID, errorReason network.ErrorReason) *FailRequestArgs
NewFailRequestArgs initializes FailRequestArgs with the required arguments.
type FulfillRequestArgs ¶
type FulfillRequestArgs struct { RequestID RequestID `json:"requestId"` // An id the client received in requestPaused event. ResponseCode int `json:"responseCode"` // An HTTP response code. ResponseHeaders []HeaderEntry `json:"responseHeaders,omitempty"` // Response headers. BinaryResponseHeaders []byte `json:"binaryResponseHeaders,omitempty"` // 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 []byte `json:"body,omitempty"` // A response body. (Encoded as a base64 string when passed over JSON) ResponsePhrase *string `json:"responsePhrase,omitempty"` // A textual representation of responseCode. If absent, a standard phrase matching responseCode is used. }
FulfillRequestArgs represents the arguments for FulfillRequest in the Fetch domain.
func NewFulfillRequestArgs ¶
func NewFulfillRequestArgs(requestID RequestID, responseCode int) *FulfillRequestArgs
NewFulfillRequestArgs initializes FulfillRequestArgs with the required arguments.
func (*FulfillRequestArgs) SetBinaryResponseHeaders ¶ added in v0.25.0
func (a *FulfillRequestArgs) SetBinaryResponseHeaders(binaryResponseHeaders []byte) *FulfillRequestArgs
SetBinaryResponseHeaders sets the BinaryResponseHeaders optional argument. 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)
func (*FulfillRequestArgs) SetBody ¶
func (a *FulfillRequestArgs) SetBody(body []byte) *FulfillRequestArgs
SetBody sets the Body optional argument. A response body. (Encoded as a base64 string when passed over JSON)
func (*FulfillRequestArgs) SetResponseHeaders ¶ added in v0.25.0
func (a *FulfillRequestArgs) SetResponseHeaders(responseHeaders []HeaderEntry) *FulfillRequestArgs
SetResponseHeaders sets the ResponseHeaders optional argument. Response headers.
func (*FulfillRequestArgs) SetResponsePhrase ¶
func (a *FulfillRequestArgs) SetResponsePhrase(responsePhrase string) *FulfillRequestArgs
SetResponsePhrase sets the ResponsePhrase optional argument. A textual representation of responseCode. If absent, a standard phrase matching responseCode is used.
type GetResponseBodyArgs ¶
type GetResponseBodyArgs struct {
RequestID RequestID `json:"requestId"` // Identifier for the intercepted request to get body for.
}
GetResponseBodyArgs represents the arguments for GetResponseBody in the Fetch domain.
func NewGetResponseBodyArgs ¶
func NewGetResponseBodyArgs(requestID RequestID) *GetResponseBodyArgs
NewGetResponseBodyArgs initializes GetResponseBodyArgs with the required arguments.
type GetResponseBodyReply ¶
type GetResponseBodyReply struct { Body string `json:"body"` // Response body. Base64Encoded bool `json:"base64Encoded"` // True, if content was sent as base64. }
GetResponseBodyReply represents the return values for GetResponseBody in the Fetch domain.
type HeaderEntry ¶
type HeaderEntry struct { Name string `json:"name"` // No description. Value string `json:"value"` // No description. }
HeaderEntry Response HTTP header entry
type RequestPattern ¶
type RequestPattern struct { URLPattern *string `json:"urlPattern,omitempty"` // Wildcards ('*' -> zero or more, '?' -> exactly one) are allowed. Escape character is backslash. Omitting is equivalent to "*". ResourceType *network.ResourceType `json:"resourceType,omitempty"` // If set, only requests for matching resource types will be intercepted. RequestStage RequestStage `json:"requestStage,omitempty"` // Stage at which to begin intercepting requests. Default is Request. }
RequestPattern
type RequestPausedClient ¶
type RequestPausedClient interface { // Recv calls RecvMsg on rpcc.Stream, blocks until the event is // triggered, context canceled or connection closed. Recv() (*RequestPausedReply, error) rpcc.Stream }
RequestPausedClient is a client for RequestPaused events. 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.
type RequestPausedReply ¶
type RequestPausedReply struct { RequestID RequestID `json:"requestId"` // Each request the page makes will have a unique id. Request network.Request `json:"request"` // The details of the request. FrameID page.FrameID `json:"frameId"` // The id of the frame that initiated the request. ResourceType network.ResourceType `json:"resourceType"` // How the requested resource will be used. ResponseErrorReason *network.ErrorReason `json:"responseErrorReason,omitempty"` // Response error if intercepted at response stage. ResponseStatusCode *int `json:"responseStatusCode,omitempty"` // Response code if intercepted at response stage. ResponseHeaders []HeaderEntry `json:"responseHeaders,omitempty"` // Response headers if intercepted at the response stage. NetworkID *RequestID `json:"networkId,omitempty"` // If the intercepted request had a corresponding Network.requestWillBeSent event fired for it, then this networkId will be the same as the requestId present in the requestWillBeSent event. }
RequestPausedReply is the reply for RequestPaused events.
type RequestStage ¶
type RequestStage string
RequestStage 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.
const ( RequestStageNotSet RequestStage = "" RequestStageRequest RequestStage = "Request" RequestStageResponse RequestStage = "Response" )
RequestStage as enums.
func (RequestStage) String ¶
func (e RequestStage) String() string
func (RequestStage) Valid ¶
func (e RequestStage) Valid() bool
type TakeResponseBodyAsStreamArgs ¶
type TakeResponseBodyAsStreamArgs struct {
RequestID RequestID `json:"requestId"` // No description.
}
TakeResponseBodyAsStreamArgs represents the arguments for TakeResponseBodyAsStream in the Fetch domain.
func NewTakeResponseBodyAsStreamArgs ¶
func NewTakeResponseBodyAsStreamArgs(requestID RequestID) *TakeResponseBodyAsStreamArgs
NewTakeResponseBodyAsStreamArgs initializes TakeResponseBodyAsStreamArgs with the required arguments.
type TakeResponseBodyAsStreamReply ¶
type TakeResponseBodyAsStreamReply struct {
Stream io.StreamHandle `json:"stream"` // No description.
}
TakeResponseBodyAsStreamReply represents the return values for TakeResponseBodyAsStream in the Fetch domain.