mirror of
https://github.com/tauri-apps/tauri.git
synced 2026-04-01 10:01:07 +02:00
This commit is contained in:
committed by
GitHub
parent
ba5560b2a1
commit
d576e8ae72
5
.changes/skip-redirects.md
Normal file
5
.changes/skip-redirects.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"tauri": patch
|
||||
---
|
||||
|
||||
Do not follow redirects when `api::http::ClientBuilder::max_redirections` is `0`.
|
||||
@@ -84,7 +84,11 @@ impl ClientBuilder {
|
||||
let mut client_builder = reqwest::Client::builder();
|
||||
|
||||
if let Some(max_redirections) = self.max_redirections {
|
||||
client_builder = client_builder.redirect(reqwest::redirect::Policy::limited(max_redirections))
|
||||
client_builder = client_builder.redirect(if max_redirections == 0 {
|
||||
reqwest::redirect::Policy::none()
|
||||
} else {
|
||||
reqwest::redirect::Policy::limited(max_redirections)
|
||||
});
|
||||
}
|
||||
|
||||
if let Some(connect_timeout) = self.connect_timeout {
|
||||
@@ -142,7 +146,11 @@ impl Client {
|
||||
}
|
||||
|
||||
if let Some(max_redirections) = self.0.max_redirections {
|
||||
request_builder = request_builder.max_redirections(max_redirections as u32);
|
||||
if max_redirections == 0 {
|
||||
request_builder = request_builder.follow_redirects(false);
|
||||
} else {
|
||||
request_builder = request_builder.max_redirections(max_redirections as u32);
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(timeout) = request.timeout {
|
||||
|
||||
@@ -52,6 +52,10 @@ interface Duration {
|
||||
|
||||
interface ClientOptions {
|
||||
maxRedirections?: number
|
||||
/**
|
||||
* Defines the maximum number of redirects the client should follow.
|
||||
* If set to 0, no redirects will be followed.
|
||||
*/
|
||||
connectTimeout?: number | Duration
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user