commit e88d8c856dbdd3cee56dc23141154c92db714c70
parent ec37004dfe750cabe26a93cc38cff064b017c209
Author: Daniel GarcĂa <dani-garcia@users.noreply.github.com>
Date: Wed, 11 Jul 2018 16:23:39 +0200
Change host url to https when it's enabled, should fix some problems downloading attachments
Diffstat:
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git 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()
};