diff mbox

hyper: Always follow redirects

Message ID 20170203034833.3024-1-andrew.donnellan@au1.ibm.com
State Accepted
Headers show

Commit Message

Andrew Donnellan Feb. 3, 2017, 3:48 a.m. UTC
From: Russell Currey <ruscur@russell.cc>

Signed-off-by: Russell Currey <ruscur@russell.cc>
Signed-off-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>

---

Applied to master, for information only

There may be an issue here with potential to redirect over from HTTPS to 
HTTP with sensitive credentials.

---
 src/main.rs | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
diff mbox

Patch

diff --git a/src/main.rs b/src/main.rs
index 80be31d..d0e0b49 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -37,6 +37,7 @@  use hyper::Client;
 use hyper::client::ProxyConfig;
 use hyper::net::HttpsConnector;
 use hyper_openssl::OpensslClient;
+use hyper::client::RedirectPolicy;
 
 use docopt::Docopt;
 
@@ -276,11 +277,15 @@  fn main() {
                                                 proxy.host_str().unwrap().to_string(),
                                                 proxy.port().unwrap_or(80),
                                                 connector, ssl);
-            Client::with_proxy_config(proxy_config)
+            let mut c = Client::with_proxy_config(proxy_config);
+            c.set_redirect_policy(RedirectPolicy::FollowAll);
+            c
         },
         _ => {
             debug!("snowpatch starting without a HTTP proxy");
-            Client::new()
+            let mut c = Client::new();
+            c.set_redirect_policy(RedirectPolicy::FollowAll);
+            c
         }
     });