fix panic if Location header is not a valid string

Closes #354
This commit is contained in:
Sean McArthur
2018-09-21 14:13:32 -07:00
parent 2db72d1593
commit 5bf94e7bdd

View File

@@ -476,7 +476,8 @@ impl Future for PendingRequest {
if should_redirect {
let loc = res.headers()
.get(LOCATION)
.map(|loc| self.url.join(loc.to_str().expect("")));
.and_then(|val| val.to_str().ok())
.map(|loc| self.url.join(loc));
if let Some(Ok(loc)) = loc {
if self.client.referer {
if let Some(referer) = make_referer(&loc, &self.url) {