File tree Expand file tree Collapse file tree 3 files changed +19
-2
lines changed
Expand file tree Collapse file tree 3 files changed +19
-2
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ " tauri " : patch
3+ ---
4+
5+ Do not follow redirects when ` api::http::ClientBuilder::max_redirections ` is ` 0 ` .
Original file line number Diff line number Diff line change @@ -84,7 +84,11 @@ impl ClientBuilder {
8484 let mut client_builder = reqwest:: Client :: builder ( ) ;
8585
8686 if let Some ( max_redirections) = self . max_redirections {
87- client_builder = client_builder. redirect ( reqwest:: redirect:: Policy :: limited ( max_redirections) )
87+ client_builder = client_builder. redirect ( if max_redirections == 0 {
88+ reqwest:: redirect:: Policy :: none ( )
89+ } else {
90+ reqwest:: redirect:: Policy :: limited ( max_redirections)
91+ } ) ;
8892 }
8993
9094 if let Some ( connect_timeout) = self . connect_timeout {
@@ -142,7 +146,11 @@ impl Client {
142146 }
143147
144148 if let Some ( max_redirections) = self . 0 . max_redirections {
145- request_builder = request_builder. max_redirections ( max_redirections as u32 ) ;
149+ if max_redirections == 0 {
150+ request_builder = request_builder. follow_redirects ( false ) ;
151+ } else {
152+ request_builder = request_builder. max_redirections ( max_redirections as u32 ) ;
153+ }
146154 }
147155
148156 if let Some ( timeout) = request. timeout {
Original file line number Diff line number Diff line change @@ -52,6 +52,10 @@ interface Duration {
5252
5353interface ClientOptions {
5454 maxRedirections ?: number
55+ /**
56+ * Defines the maximum number of redirects the client should follow.
57+ * If set to 0, no redirects will be followed.
58+ */
5559 connectTimeout ?: number | Duration
5660}
5761
You can’t perform that action at this time.
0 commit comments