browser_commander/puppeteer/api/
http_request.rs1#![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 HTTPRequest
15);
16
17impl HTTPRequest {
18 pub async fn client(&self) -> Result<CDPSession, BridgeError> {
24 self.remote.get("client").await
25 }
26
27 pub async fn url(&self) -> Result<String, BridgeError> {
33 self.remote.call("url", vec![]).await
34 }
35
36 pub async fn continue_request_overrides(&self) -> Result<Value, BridgeError> {
42 self.remote.call("continueRequestOverrides", vec![]).await
43 }
44
45 pub async fn response_for_request(&self) -> Result<Option<Value>, BridgeError> {
51 self.remote.call("responseForRequest", vec![]).await
52 }
53
54 pub async fn abort_error_reason(&self) -> Result<Option<Value>, BridgeError> {
60 self.remote.call("abortErrorReason", vec![]).await
61 }
62
63 pub async fn intercept_resolution_state(&self) -> Result<Value, BridgeError> {
69 self.remote.call("interceptResolutionState", vec![]).await
70 }
71
72 pub async fn is_intercept_resolution_handled(&self) -> Result<bool, BridgeError> {
78 self.remote.call("isInterceptResolutionHandled", vec![]).await
79 }
80
81 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 pub async fn finalize_interceptions(&self) -> Result<(), BridgeError> {
96 self.remote.call("finalizeInterceptions", vec![]).await
97 }
98
99 pub async fn resource_type(&self) -> Result<Value, BridgeError> {
105 self.remote.call("resourceType", vec![]).await
106 }
107
108 pub async fn method(&self) -> Result<String, BridgeError> {
114 self.remote.call("method", vec![]).await
115 }
116
117 pub async fn post_data(&self) -> Result<Option<String>, BridgeError> {
123 self.remote.call("postData", vec![]).await
124 }
125
126 pub async fn has_post_data(&self) -> Result<bool, BridgeError> {
132 self.remote.call("hasPostData", vec![]).await
133 }
134
135 pub async fn fetch_post_data(&self) -> Result<Option<String>, BridgeError> {
141 self.remote.call("fetchPostData", vec![]).await
142 }
143
144 pub async fn headers(&self) -> Result<Value, BridgeError> {
150 self.remote.call("headers", vec![]).await
151 }
152
153 pub async fn response(&self) -> Result<Option<HTTPResponse>, BridgeError> {
159 self.remote.call("response", vec![]).await
160 }
161
162 pub async fn frame(&self) -> Result<Option<Frame>, BridgeError> {
168 self.remote.call("frame", vec![]).await
169 }
170
171 pub async fn is_navigation_request(&self) -> Result<bool, BridgeError> {
177 self.remote.call("isNavigationRequest", vec![]).await
178 }
179
180 pub async fn initiator(&self) -> Result<Option<Value>, BridgeError> {
186 self.remote.call("initiator", vec![]).await
187 }
188
189 pub async fn redirect_chain(&self) -> Result<Vec<HTTPRequest>, BridgeError> {
195 self.remote.call("redirectChain", vec![]).await
196 }
197
198 pub async fn failure(&self) -> Result<Option<Value>, BridgeError> {
204 self.remote.call("failure", vec![]).await
205 }
206
207 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 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 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}