-
-
Notifications
You must be signed in to change notification settings - Fork 284
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Additional HTTP header with loading URL #816
Comments
Overall seems possible Windows: https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2_2?view=webview2-1.0.1462.37#navigatewithwebresourcerequest |
It's supported on Linux too, a modified load_url method could look something like this: pub fn load_url(&self, url: &str) {
let req = URIRequest::builder().uri(url).build();
let headers = req.http_headers().unwrap();
headers.append(
"My-Header",
"This only works when you're creating new requests, you can't modify ones created by the webview itself.",
);
self.webview.load_request(&req);
} |
|
Oh nice, thanks @FabianLars. Apparently, I was looking at the wrong struct https://webkitgtk.org/reference/webkit2gtk/2.32.1/WebKitURIResponse.html |
@realwakka do you have an example we can use to test this? |
Thanks! I just have tested the patch in feat/load-with-headers branch with this code below.. let webview = WebViewBuilder::new(window)?
.with_url("https://tauri.studio")?
.with_devtools(true)
.build()?;
let mut header = HeaderMap::new();
header.append("X-CUSTOM-HEADER", HeaderValue::from_static("SOME_VALUE"));
webview.load_url_with_headers("https://www.whatismybrowser.com/detect/what-http-headers-is-my-browser-sending", header); And it works correctly! I've tested in ubuntu which uses webkit2gtk. |
thanks @realwakka for testing, it will be merged soon |
@amrbashir Thanks for code! |
I want to open a URL that needs additional custom http header. Is there any way to add custom http header?
It seems that android webview has a feature what I want.
https://developer.android.com/reference/android/webkit/WebView#loadUrl(java.lang.String,%20java.util.Map%3Cjava.lang.String,%20java.lang.String%3E)
It would be good to add some function for WebviewBuilder like below.
I tried to add header with initialization_script but it failed.
Would you assign yourself to implement this feature?
The text was updated successfully, but these errors were encountered: