Skip to content

Commit

Permalink
try utf8 for location headers
Browse files Browse the repository at this point in the history
  • Loading branch information
seanmonstar committed Sep 25, 2018
1 parent cd7dbe2 commit 680387f
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/async_impl/client.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::fmt;
use std::{fmt, str};
use std::sync::Arc;
use std::time::Duration;

Expand Down Expand Up @@ -478,7 +478,10 @@ impl Future for PendingRequest {
.get(LOCATION)
.and_then(|val| {
let loc = (|| -> Option<Url> {
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() {
Expand Down

0 comments on commit 680387f

Please sign in to comment.