mirror of
https://github.com/servo/servo.git
synced 2025-06-22 16:18:59 +01:00
Use rust-http typed headers
This commit is contained in:
parent
48af4e53a9
commit
ec2111edbf
1 changed files with 13 additions and 17 deletions
|
@ -35,26 +35,22 @@ fn load(url: Url, start_chan: Chan<LoadResponse>) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
info!("got HTTP response %s, headers:", response.status.to_str())
|
// Dump headers, but only do the iteration if info!() is enabled.
|
||||||
|
info!("got HTTP response %s, headers:", response.status.to_str());
|
||||||
let is_redirect = 3 == (response.status.code() / 100);
|
info!("%?",
|
||||||
let mut redirect: Option<Url> = None;
|
for header in response.headers.iter() {
|
||||||
for header in response.headers.iter() {
|
info!(" - %s: %s", header.header_name(), header.header_value());
|
||||||
let name = header.header_name();
|
});
|
||||||
let value = header.header_value();
|
|
||||||
info!(" - %s: %s", name, value);
|
|
||||||
if is_redirect && ("Location" == name) {
|
|
||||||
redirect = Some(FromStr::from_str(value).expect("Failed to parse redirect URL"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// FIXME: detect redirect loops
|
// FIXME: detect redirect loops
|
||||||
match redirect {
|
if 3 == (response.status.code() / 100) {
|
||||||
Some(url) => {
|
match response.headers.location {
|
||||||
info!("redirecting to %s", url.to_str());
|
Some(url) => {
|
||||||
return load(url, start_chan);
|
info!("redirecting to %s", url.to_str());
|
||||||
|
return load(url, start_chan);
|
||||||
|
}
|
||||||
|
None => ()
|
||||||
}
|
}
|
||||||
None => ()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut metadata = Metadata::default(url);
|
let mut metadata = Metadata::default(url);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue