Skip to main content

rustenium_cdp_definitions/browser_protocol/fetch/
commands.rs

1use serde::{Deserialize, Serialize};
2#[doc = "Disables the fetch domain.\n[disable](https://chromedevtools.github.io/devtools-protocol/tot/Fetch/#method-disable)"]
3#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
4pub struct DisableParams {}
5#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
6pub enum DisableMethod {
7    #[serde(rename = "Fetch.disable")]
8    Disable,
9}
10#[doc = "Disables the fetch domain.\n[disable](https://chromedevtools.github.io/devtools-protocol/tot/Fetch/#method-disable)"]
11#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
12pub struct Disable {
13    pub method: DisableMethod,
14    pub params: DisableParams,
15}
16impl Disable {
17    pub const IDENTIFIER: &'static str = "Fetch.disable";
18    pub fn identifier(&self) -> &'static str {
19        Self::IDENTIFIER
20    }
21}
22impl crate::CommandResult for Disable {
23    type Result = super::results::DisableResult;
24}
25#[doc = "Enables issuing of requestPaused events. A request will be paused until client\ncalls one of failRequest, fulfillRequest or continueRequest/continueWithAuth.\n[enable](https://chromedevtools.github.io/devtools-protocol/tot/Fetch/#method-enable)"]
26#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
27pub struct EnableParams {
28    #[doc = "If specified, only requests matching any of these patterns will produce\nfetchRequested event and will be paused until clients response. If not set,\nall requests will be affected."]
29    #[serde(rename = "patterns")]
30    #[serde(skip_serializing_if = "Option::is_none")]
31    #[serde(default)]
32    pub patterns: Option<Vec<super::types::RequestPattern>>,
33    #[doc = "If true, authRequired events will be issued and requests will be paused\nexpecting a call to continueWithAuth."]
34    #[serde(rename = "handleAuthRequests")]
35    #[serde(skip_serializing_if = "Option::is_none")]
36    #[serde(default)]
37    pub handle_auth_requests: Option<bool>,
38}
39#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
40pub enum EnableMethod {
41    #[serde(rename = "Fetch.enable")]
42    Enable,
43}
44#[doc = "Enables issuing of requestPaused events. A request will be paused until client\ncalls one of failRequest, fulfillRequest or continueRequest/continueWithAuth.\n[enable](https://chromedevtools.github.io/devtools-protocol/tot/Fetch/#method-enable)"]
45#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
46pub struct Enable {
47    pub method: EnableMethod,
48    pub params: EnableParams,
49}
50impl Enable {
51    pub const IDENTIFIER: &'static str = "Fetch.enable";
52    pub fn identifier(&self) -> &'static str {
53        Self::IDENTIFIER
54    }
55}
56impl crate::CommandResult for Enable {
57    type Result = super::results::EnableResult;
58}
59#[doc = "Causes the request to fail with specified reason.\n[failRequest](https://chromedevtools.github.io/devtools-protocol/tot/Fetch/#method-failRequest)"]
60#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
61pub struct FailRequestParams {
62    #[doc = "An id the client received in requestPaused event."]
63    #[serde(rename = "requestId")]
64    pub request_id: super::types::RequestId,
65    #[doc = "Causes the request to fail with the given reason."]
66    #[serde(rename = "errorReason")]
67    pub error_reason: crate::browser_protocol::network::types::ErrorReason,
68}
69impl FailRequestParams {
70    pub fn new(
71        request_id: impl Into<super::types::RequestId>,
72        error_reason: impl Into<crate::browser_protocol::network::types::ErrorReason>,
73    ) -> Self {
74        Self {
75            request_id: request_id.into(),
76            error_reason: error_reason.into(),
77        }
78    }
79}
80#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
81pub enum FailRequestMethod {
82    #[serde(rename = "Fetch.failRequest")]
83    FailRequest,
84}
85#[doc = "Causes the request to fail with specified reason.\n[failRequest](https://chromedevtools.github.io/devtools-protocol/tot/Fetch/#method-failRequest)"]
86#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
87pub struct FailRequest {
88    pub method: FailRequestMethod,
89    pub params: FailRequestParams,
90}
91impl FailRequest {
92    pub const IDENTIFIER: &'static str = "Fetch.failRequest";
93    pub fn identifier(&self) -> &'static str {
94        Self::IDENTIFIER
95    }
96}
97impl crate::CommandResult for FailRequest {
98    type Result = super::results::FailRequestResult;
99}
100#[doc = "Provides response to the request.\n[fulfillRequest](https://chromedevtools.github.io/devtools-protocol/tot/Fetch/#method-fulfillRequest)"]
101#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
102pub struct FulfillRequestParams {
103    #[doc = "An id the client received in requestPaused event."]
104    #[serde(rename = "requestId")]
105    pub request_id: super::types::RequestId,
106    #[doc = "An HTTP response code."]
107    #[serde(rename = "responseCode")]
108    pub response_code: i64,
109    #[doc = "Response headers."]
110    #[serde(rename = "responseHeaders")]
111    #[serde(skip_serializing_if = "Option::is_none")]
112    #[serde(default)]
113    pub response_headers: Option<Vec<super::types::HeaderEntry>>,
114    #[doc = "Alternative way of specifying response headers as a \\0-separated\nseries of name: value pairs. Prefer the above method unless you\nneed to represent some non-UTF8 values that can't be transmitted\nover the protocol as text."]
115    #[serde(rename = "binaryResponseHeaders")]
116    #[serde(skip_serializing_if = "Option::is_none")]
117    #[serde(default)]
118    pub binary_response_headers: Option<crate::Binary>,
119    #[doc = "A response body. If absent, original response body will be used if\nthe request is intercepted at the response stage and empty body\nwill be used if the request is intercepted at the request stage."]
120    #[serde(rename = "body")]
121    #[serde(skip_serializing_if = "Option::is_none")]
122    #[serde(default)]
123    pub body: Option<crate::Binary>,
124    #[doc = "A textual representation of responseCode.\nIf absent, a standard phrase matching responseCode is used."]
125    #[serde(rename = "responsePhrase")]
126    #[serde(skip_serializing_if = "Option::is_none")]
127    #[serde(default)]
128    pub response_phrase: Option<String>,
129}
130impl FulfillRequestParams {
131    pub fn new(
132        request_id: impl Into<super::types::RequestId>,
133        response_code: impl Into<i64>,
134    ) -> Self {
135        Self {
136            request_id: request_id.into(),
137            response_code: response_code.into(),
138            response_headers: None,
139            binary_response_headers: None,
140            body: None,
141            response_phrase: None,
142        }
143    }
144}
145#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
146pub enum FulfillRequestMethod {
147    #[serde(rename = "Fetch.fulfillRequest")]
148    FulfillRequest,
149}
150#[doc = "Provides response to the request.\n[fulfillRequest](https://chromedevtools.github.io/devtools-protocol/tot/Fetch/#method-fulfillRequest)"]
151#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
152pub struct FulfillRequest {
153    pub method: FulfillRequestMethod,
154    pub params: FulfillRequestParams,
155}
156impl FulfillRequest {
157    pub const IDENTIFIER: &'static str = "Fetch.fulfillRequest";
158    pub fn identifier(&self) -> &'static str {
159        Self::IDENTIFIER
160    }
161}
162impl crate::CommandResult for FulfillRequest {
163    type Result = super::results::FulfillRequestResult;
164}
165#[doc = "Continues the request, optionally modifying some of its parameters.\n[continueRequest](https://chromedevtools.github.io/devtools-protocol/tot/Fetch/#method-continueRequest)"]
166#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
167pub struct ContinueRequestParams {
168    #[doc = "An id the client received in requestPaused event."]
169    #[serde(rename = "requestId")]
170    pub request_id: super::types::RequestId,
171    #[doc = "If set, the request url will be modified in a way that's not observable by page."]
172    #[serde(rename = "url")]
173    #[serde(skip_serializing_if = "Option::is_none")]
174    #[serde(default)]
175    pub url: Option<String>,
176    #[doc = "If set, the request method is overridden."]
177    #[serde(rename = "method")]
178    #[serde(skip_serializing_if = "Option::is_none")]
179    #[serde(default)]
180    pub method: Option<String>,
181    #[doc = "If set, overrides the post data in the request."]
182    #[serde(rename = "postData")]
183    #[serde(skip_serializing_if = "Option::is_none")]
184    #[serde(default)]
185    pub post_data: Option<crate::Binary>,
186    #[doc = "If set, overrides the request headers. Note that the overrides do not\nextend to subsequent redirect hops, if a redirect happens. Another override\nmay be applied to a different request produced by a redirect."]
187    #[serde(rename = "headers")]
188    #[serde(skip_serializing_if = "Option::is_none")]
189    #[serde(default)]
190    pub headers: Option<Vec<super::types::HeaderEntry>>,
191    #[doc = "If set, overrides response interception behavior for this request."]
192    #[serde(rename = "interceptResponse")]
193    #[serde(skip_serializing_if = "Option::is_none")]
194    #[serde(default)]
195    pub intercept_response: Option<bool>,
196}
197impl ContinueRequestParams {
198    pub fn new(request_id: impl Into<super::types::RequestId>) -> Self {
199        Self {
200            request_id: request_id.into(),
201            url: None,
202            method: None,
203            post_data: None,
204            headers: None,
205            intercept_response: None,
206        }
207    }
208}
209#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
210pub enum ContinueRequestMethod {
211    #[serde(rename = "Fetch.continueRequest")]
212    ContinueRequest,
213}
214#[doc = "Continues the request, optionally modifying some of its parameters.\n[continueRequest](https://chromedevtools.github.io/devtools-protocol/tot/Fetch/#method-continueRequest)"]
215#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
216pub struct ContinueRequest {
217    pub method: ContinueRequestMethod,
218    pub params: ContinueRequestParams,
219}
220impl ContinueRequest {
221    pub const IDENTIFIER: &'static str = "Fetch.continueRequest";
222    pub fn identifier(&self) -> &'static str {
223        Self::IDENTIFIER
224    }
225}
226impl crate::CommandResult for ContinueRequest {
227    type Result = super::results::ContinueRequestResult;
228}
229#[doc = "Continues a request supplying authChallengeResponse following authRequired event.\n[continueWithAuth](https://chromedevtools.github.io/devtools-protocol/tot/Fetch/#method-continueWithAuth)"]
230#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
231pub struct ContinueWithAuthParams {
232    #[doc = "An id the client received in authRequired event."]
233    #[serde(rename = "requestId")]
234    pub request_id: super::types::RequestId,
235    #[doc = "Response to  with an authChallenge."]
236    #[serde(rename = "authChallengeResponse")]
237    pub auth_challenge_response: super::types::AuthChallengeResponse,
238}
239impl ContinueWithAuthParams {
240    pub fn new(
241        request_id: impl Into<super::types::RequestId>,
242        auth_challenge_response: impl Into<super::types::AuthChallengeResponse>,
243    ) -> Self {
244        Self {
245            request_id: request_id.into(),
246            auth_challenge_response: auth_challenge_response.into(),
247        }
248    }
249}
250#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
251pub enum ContinueWithAuthMethod {
252    #[serde(rename = "Fetch.continueWithAuth")]
253    ContinueWithAuth,
254}
255#[doc = "Continues a request supplying authChallengeResponse following authRequired event.\n[continueWithAuth](https://chromedevtools.github.io/devtools-protocol/tot/Fetch/#method-continueWithAuth)"]
256#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
257pub struct ContinueWithAuth {
258    pub method: ContinueWithAuthMethod,
259    pub params: ContinueWithAuthParams,
260}
261impl ContinueWithAuth {
262    pub const IDENTIFIER: &'static str = "Fetch.continueWithAuth";
263    pub fn identifier(&self) -> &'static str {
264        Self::IDENTIFIER
265    }
266}
267impl crate::CommandResult for ContinueWithAuth {
268    type Result = super::results::ContinueWithAuthResult;
269}
270#[doc = "Continues loading of the paused response, optionally modifying the\nresponse headers. If either responseCode or headers are modified, all of them\nmust be present.\n[continueResponse](https://chromedevtools.github.io/devtools-protocol/tot/Fetch/#method-continueResponse)"]
271#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
272pub struct ContinueResponseParams {
273    #[doc = "An id the client received in requestPaused event."]
274    #[serde(rename = "requestId")]
275    pub request_id: super::types::RequestId,
276    #[doc = "An HTTP response code. If absent, original response code will be used."]
277    #[serde(rename = "responseCode")]
278    #[serde(skip_serializing_if = "Option::is_none")]
279    #[serde(default)]
280    pub response_code: Option<i64>,
281    #[doc = "A textual representation of responseCode.\nIf absent, a standard phrase matching responseCode is used."]
282    #[serde(rename = "responsePhrase")]
283    #[serde(skip_serializing_if = "Option::is_none")]
284    #[serde(default)]
285    pub response_phrase: Option<String>,
286    #[doc = "Response headers. If absent, original response headers will be used."]
287    #[serde(rename = "responseHeaders")]
288    #[serde(skip_serializing_if = "Option::is_none")]
289    #[serde(default)]
290    pub response_headers: Option<Vec<super::types::HeaderEntry>>,
291    #[doc = "Alternative way of specifying response headers as a \\0-separated\nseries of name: value pairs. Prefer the above method unless you\nneed to represent some non-UTF8 values that can't be transmitted\nover the protocol as text."]
292    #[serde(rename = "binaryResponseHeaders")]
293    #[serde(skip_serializing_if = "Option::is_none")]
294    #[serde(default)]
295    pub binary_response_headers: Option<crate::Binary>,
296}
297impl ContinueResponseParams {
298    pub fn new(request_id: impl Into<super::types::RequestId>) -> Self {
299        Self {
300            request_id: request_id.into(),
301            response_code: None,
302            response_phrase: None,
303            response_headers: None,
304            binary_response_headers: None,
305        }
306    }
307}
308#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
309pub enum ContinueResponseMethod {
310    #[serde(rename = "Fetch.continueResponse")]
311    ContinueResponse,
312}
313#[doc = "Continues loading of the paused response, optionally modifying the\nresponse headers. If either responseCode or headers are modified, all of them\nmust be present.\n[continueResponse](https://chromedevtools.github.io/devtools-protocol/tot/Fetch/#method-continueResponse)"]
314#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
315pub struct ContinueResponse {
316    pub method: ContinueResponseMethod,
317    pub params: ContinueResponseParams,
318}
319impl ContinueResponse {
320    pub const IDENTIFIER: &'static str = "Fetch.continueResponse";
321    pub fn identifier(&self) -> &'static str {
322        Self::IDENTIFIER
323    }
324}
325impl crate::CommandResult for ContinueResponse {
326    type Result = super::results::ContinueResponseResult;
327}
328#[doc = "Causes the body of the response to be received from the server and\nreturned as a single string. May only be issued for a request that\nis paused in the Response stage and is mutually exclusive with\ntakeResponseBodyForInterceptionAsStream. Calling other methods that\naffect the request or disabling fetch domain before body is received\nresults in an undefined behavior.\nNote that the response body is not available for redirects. Requests\npaused in the _redirect received_ state may be differentiated by\n`responseCode` and presence of `location` response header, see\ncomments to `requestPaused` for details.\n[getResponseBody](https://chromedevtools.github.io/devtools-protocol/tot/Fetch/#method-getResponseBody)"]
329#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
330pub struct GetResponseBodyParams {
331    #[doc = "Identifier for the intercepted request to get body for."]
332    #[serde(rename = "requestId")]
333    pub request_id: super::types::RequestId,
334}
335impl GetResponseBodyParams {
336    pub fn new(request_id: impl Into<super::types::RequestId>) -> Self {
337        Self {
338            request_id: request_id.into(),
339        }
340    }
341}
342#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
343pub enum GetResponseBodyMethod {
344    #[serde(rename = "Fetch.getResponseBody")]
345    GetResponseBody,
346}
347#[doc = "Causes the body of the response to be received from the server and\nreturned as a single string. May only be issued for a request that\nis paused in the Response stage and is mutually exclusive with\ntakeResponseBodyForInterceptionAsStream. Calling other methods that\naffect the request or disabling fetch domain before body is received\nresults in an undefined behavior.\nNote that the response body is not available for redirects. Requests\npaused in the _redirect received_ state may be differentiated by\n`responseCode` and presence of `location` response header, see\ncomments to `requestPaused` for details.\n[getResponseBody](https://chromedevtools.github.io/devtools-protocol/tot/Fetch/#method-getResponseBody)"]
348#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
349pub struct GetResponseBody {
350    pub method: GetResponseBodyMethod,
351    pub params: GetResponseBodyParams,
352}
353impl GetResponseBody {
354    pub const IDENTIFIER: &'static str = "Fetch.getResponseBody";
355    pub fn identifier(&self) -> &'static str {
356        Self::IDENTIFIER
357    }
358}
359impl crate::CommandResult for GetResponseBody {
360    type Result = super::results::GetResponseBodyResult;
361}
362#[doc = "Returns a handle to the stream representing the response body.\nThe request must be paused in the HeadersReceived stage.\nNote that after this command the request can't be continued\nas is -- client either needs to cancel it or to provide the\nresponse body.\nThe stream only supports sequential read, IO.read will fail if the position\nis specified.\nThis method is mutually exclusive with getResponseBody.\nCalling other methods that affect the request or disabling fetch\ndomain before body is received results in an undefined behavior.\n[takeResponseBodyAsStream](https://chromedevtools.github.io/devtools-protocol/tot/Fetch/#method-takeResponseBodyAsStream)"]
363#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
364pub struct TakeResponseBodyAsStreamParams {
365    #[serde(rename = "requestId")]
366    pub request_id: super::types::RequestId,
367}
368impl TakeResponseBodyAsStreamParams {
369    pub fn new(request_id: impl Into<super::types::RequestId>) -> Self {
370        Self {
371            request_id: request_id.into(),
372        }
373    }
374}
375#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
376pub enum TakeResponseBodyAsStreamMethod {
377    #[serde(rename = "Fetch.takeResponseBodyAsStream")]
378    TakeResponseBodyAsStream,
379}
380#[doc = "Returns a handle to the stream representing the response body.\nThe request must be paused in the HeadersReceived stage.\nNote that after this command the request can't be continued\nas is -- client either needs to cancel it or to provide the\nresponse body.\nThe stream only supports sequential read, IO.read will fail if the position\nis specified.\nThis method is mutually exclusive with getResponseBody.\nCalling other methods that affect the request or disabling fetch\ndomain before body is received results in an undefined behavior.\n[takeResponseBodyAsStream](https://chromedevtools.github.io/devtools-protocol/tot/Fetch/#method-takeResponseBodyAsStream)"]
381#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
382pub struct TakeResponseBodyAsStream {
383    pub method: TakeResponseBodyAsStreamMethod,
384    pub params: TakeResponseBodyAsStreamParams,
385}
386impl TakeResponseBodyAsStream {
387    pub const IDENTIFIER: &'static str = "Fetch.takeResponseBodyAsStream";
388    pub fn identifier(&self) -> &'static str {
389        Self::IDENTIFIER
390    }
391}
392impl crate::CommandResult for TakeResponseBodyAsStream {
393    type Result = super::results::TakeResponseBodyAsStreamResult;
394}
395group_enum ! (FetchCommands { Disable (Disable) , Enable (Enable) , FailRequest (FailRequest) , FulfillRequest (FulfillRequest) , ContinueRequest (ContinueRequest) , ContinueWithAuth (ContinueWithAuth) , ContinueResponse (ContinueResponse) , GetResponseBody (GetResponseBody) , TakeResponseBodyAsStream (TakeResponseBodyAsStream) } + identifiable);