viewpoint_cdp/protocol/
network.rs1use serde::{Deserialize, Serialize};
6use std::collections::HashMap;
7
8pub type RequestId = String;
10
11pub type LoaderId = String;
13
14pub type FrameId = String;
16
17#[derive(Debug, Clone, Deserialize)]
19#[serde(rename_all = "camelCase")]
20pub struct Request {
21 pub url: String,
23 pub method: String,
25 pub headers: HashMap<String, String>,
27 pub post_data: Option<String>,
29 pub has_post_data: Option<bool>,
31 pub mixed_content_type: Option<String>,
33 pub referrer_policy: Option<String>,
35 pub is_link_preload: Option<bool>,
37}
38
39#[derive(Debug, Clone, Deserialize)]
41#[serde(rename_all = "camelCase")]
42pub struct Response {
43 pub url: String,
45 pub status: u32,
47 pub status_text: String,
49 pub headers: HashMap<String, String>,
51 pub headers_text: Option<String>,
53 pub mime_type: String,
55 pub request_headers: Option<HashMap<String, String>>,
57 pub request_headers_text: Option<String>,
59 pub from_disk_cache: Option<bool>,
61 pub from_prefetch_cache: Option<bool>,
63 pub from_service_worker: Option<bool>,
65 pub encoded_data_length: Option<f64>,
67 pub protocol: Option<String>,
69 pub security_state: Option<String>,
71}
72
73#[derive(Debug, Clone, Serialize, Default)]
75#[serde(rename_all = "camelCase")]
76pub struct EnableParams {
77 #[serde(skip_serializing_if = "Option::is_none")]
79 pub max_total_buffer_size: Option<i64>,
80 #[serde(skip_serializing_if = "Option::is_none")]
82 pub max_resource_buffer_size: Option<i64>,
83 #[serde(skip_serializing_if = "Option::is_none")]
85 pub max_post_data_size: Option<i64>,
86}
87
88#[derive(Debug, Clone, Deserialize)]
90#[serde(rename_all = "camelCase")]
91pub struct RequestWillBeSentEvent {
92 pub request_id: RequestId,
94 pub loader_id: LoaderId,
96 pub document_url: String,
98 pub request: Request,
100 pub timestamp: f64,
102 pub wall_time: f64,
104 pub initiator: RequestInitiator,
106 pub frame_id: Option<FrameId>,
108 pub has_user_gesture: Option<bool>,
110 #[serde(rename = "type")]
112 pub resource_type: Option<String>,
113}
114
115#[derive(Debug, Clone, Deserialize)]
117#[serde(rename_all = "camelCase")]
118pub struct RequestInitiator {
119 #[serde(rename = "type")]
121 pub initiator_type: String,
122 pub url: Option<String>,
124 pub line_number: Option<f64>,
126 pub column_number: Option<f64>,
128}
129
130#[derive(Debug, Clone, Deserialize)]
132#[serde(rename_all = "camelCase")]
133pub struct ResponseReceivedEvent {
134 pub request_id: RequestId,
136 pub loader_id: LoaderId,
138 pub timestamp: f64,
140 #[serde(rename = "type")]
142 pub resource_type: String,
143 pub response: Response,
145 pub frame_id: Option<FrameId>,
147}
148
149#[derive(Debug, Clone, Deserialize)]
151#[serde(rename_all = "camelCase")]
152pub struct LoadingFinishedEvent {
153 pub request_id: RequestId,
155 pub timestamp: f64,
157 pub encoded_data_length: f64,
159}
160
161#[derive(Debug, Clone, Deserialize)]
163#[serde(rename_all = "camelCase")]
164pub struct LoadingFailedEvent {
165 pub request_id: RequestId,
167 pub timestamp: f64,
169 #[serde(rename = "type")]
171 pub resource_type: String,
172 pub error_text: String,
174 pub canceled: Option<bool>,
176 pub blocked_reason: Option<String>,
178}
179
180#[derive(Debug, Clone, Deserialize)]
182#[serde(rename_all = "camelCase")]
183pub struct RequestServedFromCacheEvent {
184 pub request_id: RequestId,
186}