chromiumoxide/handler/
http.rs1use chromiumoxide_cdp::cdp::browser_protocol::network::{InterceptionId, RequestId, Response};
2use chromiumoxide_cdp::cdp::browser_protocol::page::FrameId;
3
4#[derive(Default, Debug, Clone)]
5pub struct HttpRequest {
6 request_id: RequestId,
8 pub from_memory_cache: bool,
10 pub failure_text: Option<String>,
12 pub interception_id: Option<InterceptionId>,
14 pub response: Option<Response>,
16 pub headers: std::collections::HashMap<String, String>,
18 pub frame: Option<FrameId>,
20 pub is_navigation_request: bool,
22 pub allow_interception: bool,
24 pub interception_handled: bool,
26 pub method: Option<String>,
28 pub url: Option<String>,
30 pub resource_type: Option<String>,
32 pub post_data: Option<String>,
34 pub redirect_chain: Vec<HttpRequest>,
36}
37
38impl HttpRequest {
39 pub fn new(
41 request_id: RequestId,
42 frame: Option<FrameId>,
43 interception_id: Option<InterceptionId>,
44 allow_interception: bool,
45 redirect_chain: Vec<HttpRequest>,
46 ) -> Self {
47 Self {
48 request_id,
49 from_memory_cache: false,
50 failure_text: None,
51 interception_id,
52 response: None,
53 headers: Default::default(),
54 frame,
55 is_navigation_request: false,
56 allow_interception,
57 interception_handled: false,
58 method: None,
59 url: None,
60 resource_type: None,
61 post_data: None,
62 redirect_chain,
63 }
64 }
65 pub fn request_id(&self) -> &RequestId {
67 &self.request_id
68 }
69 pub fn set_response(&mut self, response: Response) {
71 self.response = Some(response)
72 }
73}