You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/main.rs
+59-1Lines changed: 59 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,9 @@
1
1
use std::borrow::Cow;
2
2
use std::cell::RefCell;
3
+
use std::collections::HashMap;
3
4
use std::env;
4
5
use std::io::{self,BufRead,Write};
6
+
use std::str::FromStr;
5
7
use std::sync::mpsc;
6
8
use std::sync::Arc;
7
9
@@ -16,6 +18,7 @@ use tao::{
16
18
event_loop::{ControlFlow,EventLoop},
17
19
window::WindowBuilder,
18
20
};
21
+
use wry::http::header::{HeaderName,HeaderValue};
19
22
use wry::http::ResponseasHttpResponse;
20
23
use wry::WebViewBuilder;
21
24
@@ -92,6 +95,9 @@ struct WebViewOptions {
92
95
#[serde(default)]
93
96
/// Run JavaScript code when loading new pages. When the webview loads a new page, this code will be executed. It is guaranteed that the code is executed before window.onload.
94
97
initialization_script:Option<String>,
98
+
/// Sets the user agent to use when loading pages.
99
+
#[serde(default)]
100
+
user_agent:Option<String>,
95
101
}
96
102
97
103
fndefault_true() -> bool{
@@ -105,6 +111,8 @@ enum WebViewTarget {
105
111
Url{
106
112
/// Url to load in the webview. Note: Don't use data URLs here, as they are not supported. Use the `html` field instead.
107
113
url:String,
114
+
/// Optional headers to send with the request.
115
+
headers:Option<HashMap<String,String>>,
108
116
},
109
117
Html{
110
118
/// Html to load in the webview.
@@ -232,6 +240,14 @@ enum Request {
232
240
/// If not specified, the origin will be set to the value of the `origin` field when the webview was created.
0 commit comments