From e88d8c856dbdd3cee56dc23141154c92db714c70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Garc=C3=ADa?= Date: Wed, 11 Jul 2018 16:23:39 +0200 Subject: [PATCH] Change host url to https when it's enabled, should fix some problems downloading attachments --- src/auth.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/auth.rs b/src/auth.rs index 0aa7a682..186fbf48 100644 --- a/src/auth.rs +++ b/src/auth.rs @@ -111,7 +111,11 @@ impl<'a, 'r> FromRequest<'a, 'r> for Headers { // Get host let host = match headers.get_one("Host") { - Some(host) => format!("http://{}", host), // TODO: Check if HTTPS + Some(host) => { + use std::env; + let protocol = if env::var("ROCKET_TLS").is_ok() {"https"} else {"http"}; + format!("{}://{}", protocol, host) + }, _ => String::new() };