From 680387f790af45ee1f919bf0d4968ac543aadacd Mon Sep 17 00:00:00 2001 From: Sean McArthur Date: Tue, 25 Sep 2018 11:46:46 -0700 Subject: [PATCH] try utf8 for location headers --- src/async_impl/client.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/async_impl/client.rs b/src/async_impl/client.rs index db6a844..a60c356 100644 --- a/src/async_impl/client.rs +++ b/src/async_impl/client.rs @@ -1,4 +1,4 @@ -use std::fmt; +use std::{fmt, str}; use std::sync::Arc; use std::time::Duration; @@ -478,7 +478,10 @@ impl Future for PendingRequest { .get(LOCATION) .and_then(|val| { let loc = (|| -> Option { - self.url.join(val.to_str().ok()?).ok() + // Some sites may send a utf-8 Location header, + // even though we're supposed to treat those bytes + // as opaque, we'll check specifically for utf8. + self.url.join(str::from_utf8(val.as_bytes()).ok()?).ok() })(); if loc.is_none() {