chromiumoxide/handler/
http.rs1use chromiumoxide_cdp::cdp::browser_protocol::network::{InterceptionId, RequestId, Response};
2use chromiumoxide_cdp::cdp::browser_protocol::page::FrameId;
3
4#[derive(Debug, Clone)]
5pub struct HttpRequest {
6 request_id: RequestId,
7 pub from_memory_cache: bool,
8 pub failure_text: Option<String>,
9 pub interception_id: Option<InterceptionId>,
10 pub response: Option<Response>,
11 pub headers: std::collections::HashMap<String, String>,
12 pub frame: Option<FrameId>,
13 pub is_navigation_request: bool,
14 pub allow_interception: bool,
15 pub interception_handled: bool,
16 pub method: Option<String>,
17 pub url: Option<String>,
18 pub resource_type: Option<String>,
19 pub post_data: Option<String>,
20 pub redirect_chain: Vec<HttpRequest>,
21}
22
23impl HttpRequest {
24 pub fn new(
25 request_id: RequestId,
26 frame: Option<FrameId>,
27 interception_id: Option<InterceptionId>,
28 allow_interception: bool,
29 redirect_chain: Vec<HttpRequest>,
30 ) -> Self {
31 Self {
32 request_id,
33 from_memory_cache: false,
34 failure_text: None,
35 interception_id,
36 response: None,
37 headers: Default::default(),
38 frame,
39 is_navigation_request: false,
40 allow_interception,
41 interception_handled: false,
42 method: None,
43 url: None,
44 resource_type: None,
45 post_data: None,
46 redirect_chain,
47 }
48 }
49
50 pub fn request_id(&self) -> &RequestId {
51 &self.request_id
52 }
53
54 pub(crate) fn set_response(&mut self, response: Response) {
55 self.response = Some(response)
56 }
57}