vendor/github.com/go-rod/rod/lib/proto/fetch.go
408 lines · 15990 bytes
1// This file is generated by "./lib/proto/generate"
2
3package proto
4
5/*
6
7Fetch
8
9A domain for letting clients substitute browser's network layer with client code.
10
11*/
12
13// FetchRequestID Unique request identifier.
14type FetchRequestID string
15
16// FetchRequestStage Stages of the request to handle. Request will intercept before the request is
17// sent. Response will intercept after the response is received (but before response
18// body is received).
19type FetchRequestStage string
20
21const (
22 // FetchRequestStageRequest enum const.
23 FetchRequestStageRequest FetchRequestStage = "Request"
24
25 // FetchRequestStageResponse enum const.
26 FetchRequestStageResponse FetchRequestStage = "Response"
27)
28
29// FetchRequestPattern ...
30type FetchRequestPattern struct {
31 // URLPattern (optional) Wildcards (`'*'` -> zero or more, `'?'` -> exactly one) are allowed. Escape character is
32 // backslash. Omitting is equivalent to `"*"`.
33 URLPattern string `json:"urlPattern,omitempty"`
34
35 // ResourceType (optional) If set, only requests for matching resource types will be intercepted.
36 ResourceType NetworkResourceType `json:"resourceType,omitempty"`
37
38 // RequestStage (optional) Stage at which to begin intercepting requests. Default is Request.
39 RequestStage FetchRequestStage `json:"requestStage,omitempty"`
40}
41
42// FetchHeaderEntry Response HTTP header entry.
43type FetchHeaderEntry struct {
44 // Name ...
45 Name string `json:"name"`
46
47 // Value ...
48 Value string `json:"value"`
49}
50
51// FetchAuthChallengeSource enum.
52type FetchAuthChallengeSource string
53
54const (
55 // FetchAuthChallengeSourceServer enum const.
56 FetchAuthChallengeSourceServer FetchAuthChallengeSource = "Server"
57
58 // FetchAuthChallengeSourceProxy enum const.
59 FetchAuthChallengeSourceProxy FetchAuthChallengeSource = "Proxy"
60)
61
62// FetchAuthChallenge Authorization challenge for HTTP status code 401 or 407.
63type FetchAuthChallenge struct {
64 // Source (optional) Source of the authentication challenge.
65 Source FetchAuthChallengeSource `json:"source,omitempty"`
66
67 // Origin of the challenger.
68 Origin string `json:"origin"`
69
70 // Scheme The authentication scheme used, such as basic or digest
71 Scheme string `json:"scheme"`
72
73 // Realm The realm of the challenge. May be empty.
74 Realm string `json:"realm"`
75}
76
77// FetchAuthChallengeResponseResponse enum.
78type FetchAuthChallengeResponseResponse string
79
80const (
81 // FetchAuthChallengeResponseResponseDefault enum const.
82 FetchAuthChallengeResponseResponseDefault FetchAuthChallengeResponseResponse = "Default"
83
84 // FetchAuthChallengeResponseResponseCancelAuth enum const.
85 FetchAuthChallengeResponseResponseCancelAuth FetchAuthChallengeResponseResponse = "CancelAuth"
86
87 // FetchAuthChallengeResponseResponseProvideCredentials enum const.
88 FetchAuthChallengeResponseResponseProvideCredentials FetchAuthChallengeResponseResponse = "ProvideCredentials"
89)
90
91// FetchAuthChallengeResponse Response to an AuthChallenge.
92type FetchAuthChallengeResponse struct {
93 // Response The decision on what to do in response to the authorization challenge. Default means
94 // deferring to the default behavior of the net stack, which will likely either the Cancel
95 // authentication or display a popup dialog box.
96 Response FetchAuthChallengeResponseResponse `json:"response"`
97
98 // Username (optional) The username to provide, possibly empty. Should only be set if response is
99 // ProvideCredentials.
100 Username string `json:"username,omitempty"`
101
102 // Password (optional) The password to provide, possibly empty. Should only be set if response is
103 // ProvideCredentials.
104 Password string `json:"password,omitempty"`
105}
106
107// FetchDisable Disables the fetch domain.
108type FetchDisable struct{}
109
110// ProtoReq name.
111func (m FetchDisable) ProtoReq() string { return "Fetch.disable" }
112
113// Call sends the request.
114func (m FetchDisable) Call(c Client) error {
115 return call(m.ProtoReq(), m, nil, c)
116}
117
118// FetchEnable Enables issuing of requestPaused events. A request will be paused until client
119// calls one of failRequest, fulfillRequest or continueRequest/continueWithAuth.
120type FetchEnable struct {
121 // Patterns (optional) If specified, only requests matching any of these patterns will produce
122 // fetchRequested event and will be paused until clients response. If not set,
123 // all requests will be affected.
124 Patterns []*FetchRequestPattern `json:"patterns,omitempty"`
125
126 // HandleAuthRequests (optional) If true, authRequired events will be issued and requests will be paused
127 // expecting a call to continueWithAuth.
128 HandleAuthRequests bool `json:"handleAuthRequests,omitempty"`
129}
130
131// ProtoReq name.
132func (m FetchEnable) ProtoReq() string { return "Fetch.enable" }
133
134// Call sends the request.
135func (m FetchEnable) Call(c Client) error {
136 return call(m.ProtoReq(), m, nil, c)
137}
138
139// FetchFailRequest Causes the request to fail with specified reason.
140type FetchFailRequest struct {
141 // RequestID An id the client received in requestPaused event.
142 RequestID FetchRequestID `json:"requestId"`
143
144 // ErrorReason Causes the request to fail with the given reason.
145 ErrorReason NetworkErrorReason `json:"errorReason"`
146}
147
148// ProtoReq name.
149func (m FetchFailRequest) ProtoReq() string { return "Fetch.failRequest" }
150
151// Call sends the request.
152func (m FetchFailRequest) Call(c Client) error {
153 return call(m.ProtoReq(), m, nil, c)
154}
155
156// FetchFulfillRequest Provides response to the request.
157type FetchFulfillRequest struct {
158 // RequestID An id the client received in requestPaused event.
159 RequestID FetchRequestID `json:"requestId"`
160
161 // ResponseCode An HTTP response code.
162 ResponseCode int `json:"responseCode"`
163
164 // ResponseHeaders (optional) Response headers.
165 ResponseHeaders []*FetchHeaderEntry `json:"responseHeaders,omitempty"`
166
167 // BinaryResponseHeaders (optional) Alternative way of specifying response headers as a \0-separated
168 // series of name: value pairs. Prefer the above method unless you
169 // need to represent some non-UTF8 values that can't be transmitted
170 // over the protocol as text.
171 BinaryResponseHeaders []byte `json:"binaryResponseHeaders,omitempty"`
172
173 // Body A response body. If absent, original response body will be used if
174 // the request is intercepted at the response stage and empty body
175 // will be used if the request is intercepted at the request stage.
176 Body []byte `json:"body"`
177
178 // ResponsePhrase (optional) A textual representation of responseCode.
179 // If absent, a standard phrase matching responseCode is used.
180 ResponsePhrase string `json:"responsePhrase,omitempty"`
181}
182
183// ProtoReq name.
184func (m FetchFulfillRequest) ProtoReq() string { return "Fetch.fulfillRequest" }
185
186// Call sends the request.
187func (m FetchFulfillRequest) Call(c Client) error {
188 return call(m.ProtoReq(), m, nil, c)
189}
190
191// FetchContinueRequest Continues the request, optionally modifying some of its parameters.
192type FetchContinueRequest struct {
193 // RequestID An id the client received in requestPaused event.
194 RequestID FetchRequestID `json:"requestId"`
195
196 // URL (optional) If set, the request url will be modified in a way that's not observable by page.
197 URL string `json:"url,omitempty"`
198
199 // Method (optional) If set, the request method is overridden.
200 Method string `json:"method,omitempty"`
201
202 // PostData (optional) If set, overrides the post data in the request.
203 PostData []byte `json:"postData,omitempty"`
204
205 // Headers (optional) If set, overrides the request headers. Note that the overrides do not
206 // extend to subsequent redirect hops, if a redirect happens. Another override
207 // may be applied to a different request produced by a redirect.
208 Headers []*FetchHeaderEntry `json:"headers,omitempty"`
209
210 // InterceptResponse (experimental) (optional) If set, overrides response interception behavior for this request.
211 InterceptResponse bool `json:"interceptResponse,omitempty"`
212}
213
214// ProtoReq name.
215func (m FetchContinueRequest) ProtoReq() string { return "Fetch.continueRequest" }
216
217// Call sends the request.
218func (m FetchContinueRequest) Call(c Client) error {
219 return call(m.ProtoReq(), m, nil, c)
220}
221
222// FetchContinueWithAuth Continues a request supplying authChallengeResponse following authRequired event.
223type FetchContinueWithAuth struct {
224 // RequestID An id the client received in authRequired event.
225 RequestID FetchRequestID `json:"requestId"`
226
227 // AuthChallengeResponse Response to with an authChallenge.
228 AuthChallengeResponse *FetchAuthChallengeResponse `json:"authChallengeResponse"`
229}
230
231// ProtoReq name.
232func (m FetchContinueWithAuth) ProtoReq() string { return "Fetch.continueWithAuth" }
233
234// Call sends the request.
235func (m FetchContinueWithAuth) Call(c Client) error {
236 return call(m.ProtoReq(), m, nil, c)
237}
238
239// FetchContinueResponse (experimental) Continues loading of the paused response, optionally modifying the
240// response headers. If either responseCode or headers are modified, all of them
241// must be present.
242type FetchContinueResponse struct {
243 // RequestID An id the client received in requestPaused event.
244 RequestID FetchRequestID `json:"requestId"`
245
246 // ResponseCode (optional) An HTTP response code. If absent, original response code will be used.
247 ResponseCode *int `json:"responseCode,omitempty"`
248
249 // ResponsePhrase (optional) A textual representation of responseCode.
250 // If absent, a standard phrase matching responseCode is used.
251 ResponsePhrase string `json:"responsePhrase,omitempty"`
252
253 // ResponseHeaders (optional) Response headers. If absent, original response headers will be used.
254 ResponseHeaders []*FetchHeaderEntry `json:"responseHeaders,omitempty"`
255
256 // BinaryResponseHeaders (optional) Alternative way of specifying response headers as a \0-separated
257 // series of name: value pairs. Prefer the above method unless you
258 // need to represent some non-UTF8 values that can't be transmitted
259 // over the protocol as text.
260 BinaryResponseHeaders []byte `json:"binaryResponseHeaders,omitempty"`
261}
262
263// ProtoReq name.
264func (m FetchContinueResponse) ProtoReq() string { return "Fetch.continueResponse" }
265
266// Call sends the request.
267func (m FetchContinueResponse) Call(c Client) error {
268 return call(m.ProtoReq(), m, nil, c)
269}
270
271// FetchGetResponseBody Causes the body of the response to be received from the server and
272// returned as a single string. May only be issued for a request that
273// is paused in the Response stage and is mutually exclusive with
274// takeResponseBodyForInterceptionAsStream. Calling other methods that
275// affect the request or disabling fetch domain before body is received
276// results in an undefined behavior.
277// Note that the response body is not available for redirects. Requests
278// paused in the _redirect received_ state may be differentiated by
279// `responseCode` and presence of `location` response header, see
280// comments to `requestPaused` for details.
281type FetchGetResponseBody struct {
282 // RequestID Identifier for the intercepted request to get body for.
283 RequestID FetchRequestID `json:"requestId"`
284}
285
286// ProtoReq name.
287func (m FetchGetResponseBody) ProtoReq() string { return "Fetch.getResponseBody" }
288
289// Call the request.
290func (m FetchGetResponseBody) Call(c Client) (*FetchGetResponseBodyResult, error) {
291 var res FetchGetResponseBodyResult
292 return &res, call(m.ProtoReq(), m, &res, c)
293}
294
295// FetchGetResponseBodyResult ...
296type FetchGetResponseBodyResult struct {
297 // Body Response body.
298 Body string `json:"body"`
299
300 // Base64Encoded True, if content was sent as base64.
301 Base64Encoded bool `json:"base64Encoded"`
302}
303
304// FetchTakeResponseBodyAsStream Returns a handle to the stream representing the response body.
305// The request must be paused in the HeadersReceived stage.
306// Note that after this command the request can't be continued
307// as is -- client either needs to cancel it or to provide the
308// response body.
309// The stream only supports sequential read, IO.read will fail if the position
310// is specified.
311// This method is mutually exclusive with getResponseBody.
312// Calling other methods that affect the request or disabling fetch
313// domain before body is received results in an undefined behavior.
314type FetchTakeResponseBodyAsStream struct {
315 // RequestID ...
316 RequestID FetchRequestID `json:"requestId"`
317}
318
319// ProtoReq name.
320func (m FetchTakeResponseBodyAsStream) ProtoReq() string { return "Fetch.takeResponseBodyAsStream" }
321
322// Call the request.
323func (m FetchTakeResponseBodyAsStream) Call(c Client) (*FetchTakeResponseBodyAsStreamResult, error) {
324 var res FetchTakeResponseBodyAsStreamResult
325 return &res, call(m.ProtoReq(), m, &res, c)
326}
327
328// FetchTakeResponseBodyAsStreamResult ...
329type FetchTakeResponseBodyAsStreamResult struct {
330 // Stream ...
331 Stream IOStreamHandle `json:"stream"`
332}
333
334// FetchRequestPaused Issued when the domain is enabled and the request URL matches the
335// specified filter. The request is paused until the client responds
336// with one of continueRequest, failRequest or fulfillRequest.
337// The stage of the request can be determined by presence of responseErrorReason
338// and responseStatusCode -- the request is at the response stage if either
339// of these fields is present and in the request stage otherwise.
340// Redirect responses and subsequent requests are reported similarly to regular
341// responses and requests. Redirect responses may be distinguished by the value
342// of `responseStatusCode` (which is one of 301, 302, 303, 307, 308) along with
343// presence of the `location` header. Requests resulting from a redirect will
344// have `redirectedRequestId` field set.
345type FetchRequestPaused struct {
346 // RequestID Each request the page makes will have a unique id.
347 RequestID FetchRequestID `json:"requestId"`
348
349 // Request The details of the request.
350 Request *NetworkRequest `json:"request"`
351
352 // FrameID The id of the frame that initiated the request.
353 FrameID PageFrameID `json:"frameId"`
354
355 // ResourceType How the requested resource will be used.
356 ResourceType NetworkResourceType `json:"resourceType"`
357
358 // ResponseErrorReason (optional) Response error if intercepted at response stage.
359 ResponseErrorReason NetworkErrorReason `json:"responseErrorReason,omitempty"`
360
361 // ResponseStatusCode (optional) Response code if intercepted at response stage.
362 ResponseStatusCode *int `json:"responseStatusCode,omitempty"`
363
364 // ResponseStatusText (optional) Response status text if intercepted at response stage.
365 ResponseStatusText string `json:"responseStatusText,omitempty"`
366
367 // ResponseHeaders (optional) Response headers if intercepted at the response stage.
368 ResponseHeaders []*FetchHeaderEntry `json:"responseHeaders,omitempty"`
369
370 // NetworkID (optional) If the intercepted request had a corresponding Network.requestWillBeSent event fired for it,
371 // then this networkId will be the same as the requestId present in the requestWillBeSent event.
372 NetworkID NetworkRequestID `json:"networkId,omitempty"`
373
374 // RedirectedRequestID (experimental) (optional) If the request is due to a redirect response from the server, the id of the request that
375 // has caused the redirect.
376 RedirectedRequestID FetchRequestID `json:"redirectedRequestId,omitempty"`
377}
378
379// ProtoEvent name.
380func (evt FetchRequestPaused) ProtoEvent() string {
381 return "Fetch.requestPaused"
382}
383
384// FetchAuthRequired Issued when the domain is enabled with handleAuthRequests set to true.
385// The request is paused until client responds with continueWithAuth.
386type FetchAuthRequired struct {
387 // RequestID Each request the page makes will have a unique id.
388 RequestID FetchRequestID `json:"requestId"`
389
390 // Request The details of the request.
391 Request *NetworkRequest `json:"request"`
392
393 // FrameID The id of the frame that initiated the request.
394 FrameID PageFrameID `json:"frameId"`
395
396 // ResourceType How the requested resource will be used.
397 ResourceType NetworkResourceType `json:"resourceType"`
398
399 // AuthChallenge Details of the Authorization Challenge encountered.
400 // If this is set, client should respond with continueRequest that
401 // contains AuthChallengeResponse.
402 AuthChallenge *FetchAuthChallenge `json:"authChallenge"`
403}
404
405// ProtoEvent name.
406func (evt FetchAuthRequired) ProtoEvent() string {
407 return "Fetch.authRequired"
408}