Bad HTTP responses now have a 0 status code instead of 200 OK.
This commit is contained in:
Jesse Tuchsen 2014-11-27 10:01:38 -08:00
parent 431644bfc8
commit b664ee88e7
5 changed files with 14 additions and 22 deletions

View file

@ -19,7 +19,7 @@ pub fn factory(mut load_data: LoadData, start_chan: Sender<LoadResponse>) {
content_type: Some(("text".to_string(), "html".to_string())),
charset: Some("utf-8".to_string()),
headers: None,
status: StatusOk,
status: Some(StatusOk),
});
chan.send(Done(Ok(())));
return

View file

@ -17,7 +17,10 @@ pub fn factory(load_data: LoadData, start_chan: Sender<LoadResponse>) {
}
fn send_error(url: Url, err: String, start_chan: Sender<LoadResponse>) {
match start_sending_opt(start_chan, Metadata::default(url)) {
let mut metadata = Metadata::default(url);
metadata.status = None;
match start_sending_opt(start_chan, metadata) {
Ok(p) => p.send(Done(Err(err))),
_ => {}
};
@ -133,7 +136,7 @@ fn load(load_data: LoadData, start_chan: Sender<LoadResponse>) {
let mut metadata = Metadata::default(url);
metadata.set_content_type(&response.headers.content_type);
metadata.headers = Some(response.headers.clone());
metadata.status = response.status.clone();
metadata.status = Some(response.status.clone());
let progress_chan = match start_sending_opt(start_chan, metadata) {
Ok(p) => p,

View file

@ -72,7 +72,7 @@ pub struct Metadata {
pub headers: Option<ResponseHeaderCollection>,
/// HTTP Status
pub status: Status
pub status: Option<Status>
}
impl Metadata {
@ -83,7 +83,7 @@ impl Metadata {
content_type: None,
charset: None,
headers: None,
status: StatusOk // http://fetch.spec.whatwg.org/#concept-response-status-message
status: Some(StatusOk) // http://fetch.spec.whatwg.org/#concept-response-status-message
}
}