Skip to main content

browser_commander/puppeteer/api/
http_request.rs

1// @generated by scripts/generate-puppeteer-bindings.mjs from
2// rust/protocol/puppeteer/api.json. Do not edit by hand.
3
4#![allow(clippy::all, missing_docs, unused_imports, non_snake_case)]
5
6use serde_json::Value;
7
8use super::*;
9use crate::puppeteer::bridge::{binary, remote_type, BridgeError, JsFunction, Remote};
10
11remote_type!(
12    /// Puppeteer's `HTTPRequest` (puppeteer-core 25.10.0), a remote object
13    /// served by `browser-commander serve --stdio`.
14    HTTPRequest
15);
16
17impl HTTPRequest {
18    /// `HTTPRequest.client`
19    ///
20    /// ```text
21    /// get client(): CDPSession
22    /// ```
23    pub async fn client(&self) -> Result<CDPSession, BridgeError> {
24        self.remote.get("client").await
25    }
26
27    /// `HTTPRequest.url`
28    ///
29    /// ```text
30    /// url(): string
31    /// ```
32    pub async fn url(&self) -> Result<String, BridgeError> {
33        self.remote.call("url", vec![]).await
34    }
35
36    /// `HTTPRequest.continueRequestOverrides`
37    ///
38    /// ```text
39    /// continueRequestOverrides(): ContinueRequestOverrides
40    /// ```
41    pub async fn continue_request_overrides(&self) -> Result<Value, BridgeError> {
42        self.remote.call("continueRequestOverrides", vec![]).await
43    }
44
45    /// `HTTPRequest.responseForRequest`
46    ///
47    /// ```text
48    /// responseForRequest(): Partial<ResponseForRequest> | null
49    /// ```
50    pub async fn response_for_request(&self) -> Result<Option<Value>, BridgeError> {
51        self.remote.call("responseForRequest", vec![]).await
52    }
53
54    /// `HTTPRequest.abortErrorReason`
55    ///
56    /// ```text
57    /// abortErrorReason(): Protocol.Network.ErrorReason | null
58    /// ```
59    pub async fn abort_error_reason(&self) -> Result<Option<Value>, BridgeError> {
60        self.remote.call("abortErrorReason", vec![]).await
61    }
62
63    /// `HTTPRequest.interceptResolutionState`
64    ///
65    /// ```text
66    /// interceptResolutionState(): InterceptResolutionState
67    /// ```
68    pub async fn intercept_resolution_state(&self) -> Result<Value, BridgeError> {
69        self.remote.call("interceptResolutionState", vec![]).await
70    }
71
72    /// `HTTPRequest.isInterceptResolutionHandled`
73    ///
74    /// ```text
75    /// isInterceptResolutionHandled(): boolean
76    /// ```
77    pub async fn is_intercept_resolution_handled(&self) -> Result<bool, BridgeError> {
78        self.remote.call("isInterceptResolutionHandled", vec![]).await
79    }
80
81    /// `HTTPRequest.enqueueInterceptAction`
82    ///
83    /// ```text
84    /// enqueueInterceptAction(pendingHandler: () => void | PromiseLike<unknown>): void
85    /// ```
86    pub async fn enqueue_intercept_action(&self, pending_handler: impl Into<JsFunction>) -> Result<(), BridgeError> {
87        self.remote.call("enqueueInterceptAction", vec![Some(pending_handler.into().to_wire())]).await
88    }
89
90    /// `HTTPRequest.finalizeInterceptions`
91    ///
92    /// ```text
93    /// finalizeInterceptions(): Promise<void>
94    /// ```
95    pub async fn finalize_interceptions(&self) -> Result<(), BridgeError> {
96        self.remote.call("finalizeInterceptions", vec![]).await
97    }
98
99    /// `HTTPRequest.resourceType`
100    ///
101    /// ```text
102    /// resourceType(): ResourceType
103    /// ```
104    pub async fn resource_type(&self) -> Result<Value, BridgeError> {
105        self.remote.call("resourceType", vec![]).await
106    }
107
108    /// `HTTPRequest.method`
109    ///
110    /// ```text
111    /// method(): string
112    /// ```
113    pub async fn method(&self) -> Result<String, BridgeError> {
114        self.remote.call("method", vec![]).await
115    }
116
117    /// `HTTPRequest.postData`
118    ///
119    /// ```text
120    /// postData(): string | undefined
121    /// ```
122    pub async fn post_data(&self) -> Result<Option<String>, BridgeError> {
123        self.remote.call("postData", vec![]).await
124    }
125
126    /// `HTTPRequest.hasPostData`
127    ///
128    /// ```text
129    /// hasPostData(): boolean
130    /// ```
131    pub async fn has_post_data(&self) -> Result<bool, BridgeError> {
132        self.remote.call("hasPostData", vec![]).await
133    }
134
135    /// `HTTPRequest.fetchPostData`
136    ///
137    /// ```text
138    /// fetchPostData(): Promise<string | undefined>
139    /// ```
140    pub async fn fetch_post_data(&self) -> Result<Option<String>, BridgeError> {
141        self.remote.call("fetchPostData", vec![]).await
142    }
143
144    /// `HTTPRequest.headers`
145    ///
146    /// ```text
147    /// headers(): Record<string, string>
148    /// ```
149    pub async fn headers(&self) -> Result<Value, BridgeError> {
150        self.remote.call("headers", vec![]).await
151    }
152
153    /// `HTTPRequest.response`
154    ///
155    /// ```text
156    /// response(): HTTPResponse | null
157    /// ```
158    pub async fn response(&self) -> Result<Option<HTTPResponse>, BridgeError> {
159        self.remote.call("response", vec![]).await
160    }
161
162    /// `HTTPRequest.frame`
163    ///
164    /// ```text
165    /// frame(): Frame | null
166    /// ```
167    pub async fn frame(&self) -> Result<Option<Frame>, BridgeError> {
168        self.remote.call("frame", vec![]).await
169    }
170
171    /// `HTTPRequest.isNavigationRequest`
172    ///
173    /// ```text
174    /// isNavigationRequest(): boolean
175    /// ```
176    pub async fn is_navigation_request(&self) -> Result<bool, BridgeError> {
177        self.remote.call("isNavigationRequest", vec![]).await
178    }
179
180    /// `HTTPRequest.initiator`
181    ///
182    /// ```text
183    /// initiator(): Protocol.Network.Initiator | undefined
184    /// ```
185    pub async fn initiator(&self) -> Result<Option<Value>, BridgeError> {
186        self.remote.call("initiator", vec![]).await
187    }
188
189    /// `HTTPRequest.redirectChain`
190    ///
191    /// ```text
192    /// redirectChain(): HTTPRequest[]
193    /// ```
194    pub async fn redirect_chain(&self) -> Result<Vec<HTTPRequest>, BridgeError> {
195        self.remote.call("redirectChain", vec![]).await
196    }
197
198    /// `HTTPRequest.failure`
199    ///
200    /// ```text
201    /// failure(): { errorText: string; } | null
202    /// ```
203    pub async fn failure(&self) -> Result<Option<Value>, BridgeError> {
204        self.remote.call("failure", vec![]).await
205    }
206
207    /// `HTTPRequest.continue`
208    ///
209    /// ```text
210    /// continue(overrides?: ContinueRequestOverrides, priority?: number): Promise<void>
211    /// ```
212    pub async fn r#continue(&self, overrides: Option<Value>, priority: Option<f64>) -> Result<(), BridgeError> {
213        self.remote.call("continue", vec![overrides, priority.map(|x| Value::from(x))]).await
214    }
215
216    /// `HTTPRequest.respond`
217    ///
218    /// ```text
219    /// respond(response: Partial<ResponseForRequest>, priority?: number): Promise<void>
220    /// ```
221    pub async fn respond(&self, response: Value, priority: Option<f64>) -> Result<(), BridgeError> {
222        self.remote.call("respond", vec![Some(response), priority.map(|x| Value::from(x))]).await
223    }
224
225    /// `HTTPRequest.abort`
226    ///
227    /// ```text
228    /// abort(errorCode?: ErrorCode, priority?: number): Promise<void>
229    /// ```
230    pub async fn abort(&self, error_code: Option<&str>, priority: Option<f64>) -> Result<(), BridgeError> {
231        self.remote.call("abort", vec![error_code.map(|x| Value::from(x)), priority.map(|x| Value::from(x))]).await
232    }
233}