mirror of
https://github.com/servo/servo.git
synced 2025-07-23 15:23:42 +01:00
Fixes #3962
Bad HTTP responses now have a 0 status code instead of 200 OK.
This commit is contained in:
parent
431644bfc8
commit
b664ee88e7
5 changed files with 14 additions and 22 deletions
|
@ -19,7 +19,7 @@ pub fn factory(mut load_data: LoadData, start_chan: Sender<LoadResponse>) {
|
||||||
content_type: Some(("text".to_string(), "html".to_string())),
|
content_type: Some(("text".to_string(), "html".to_string())),
|
||||||
charset: Some("utf-8".to_string()),
|
charset: Some("utf-8".to_string()),
|
||||||
headers: None,
|
headers: None,
|
||||||
status: StatusOk,
|
status: Some(StatusOk),
|
||||||
});
|
});
|
||||||
chan.send(Done(Ok(())));
|
chan.send(Done(Ok(())));
|
||||||
return
|
return
|
||||||
|
|
|
@ -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>) {
|
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))),
|
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);
|
let mut metadata = Metadata::default(url);
|
||||||
metadata.set_content_type(&response.headers.content_type);
|
metadata.set_content_type(&response.headers.content_type);
|
||||||
metadata.headers = Some(response.headers.clone());
|
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) {
|
let progress_chan = match start_sending_opt(start_chan, metadata) {
|
||||||
Ok(p) => p,
|
Ok(p) => p,
|
||||||
|
|
|
@ -72,7 +72,7 @@ pub struct Metadata {
|
||||||
pub headers: Option<ResponseHeaderCollection>,
|
pub headers: Option<ResponseHeaderCollection>,
|
||||||
|
|
||||||
/// HTTP Status
|
/// HTTP Status
|
||||||
pub status: Status
|
pub status: Option<Status>
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Metadata {
|
impl Metadata {
|
||||||
|
@ -83,7 +83,7 @@ impl Metadata {
|
||||||
content_type: None,
|
content_type: None,
|
||||||
charset: None,
|
charset: None,
|
||||||
headers: 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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -88,7 +88,7 @@ pub struct GenerationId(uint);
|
||||||
|
|
||||||
pub enum XHRProgress {
|
pub enum XHRProgress {
|
||||||
/// Notify that headers have been received
|
/// Notify that headers have been received
|
||||||
HeadersReceivedMsg(GenerationId, Option<ResponseHeaderCollection>, Status),
|
HeadersReceivedMsg(GenerationId, Option<ResponseHeaderCollection>, Option<Status>),
|
||||||
/// Partial progress (after receiving headers), containing portion of the response
|
/// Partial progress (after receiving headers), containing portion of the response
|
||||||
LoadingMsg(GenerationId, ByteString),
|
LoadingMsg(GenerationId, ByteString),
|
||||||
/// Loading is done
|
/// Loading is done
|
||||||
|
@ -874,8 +874,11 @@ impl<'a> PrivateXMLHttpRequestHelpers for JSRef<'a, XMLHttpRequest> {
|
||||||
// Part of step 13, send() (processing response)
|
// Part of step 13, send() (processing response)
|
||||||
// XXXManishearth handle errors, if any (substep 1)
|
// XXXManishearth handle errors, if any (substep 1)
|
||||||
// Substep 2
|
// Substep 2
|
||||||
*self.status_text.borrow_mut() = ByteString::new(status.reason().into_bytes());
|
let status_text = status.as_ref().map_or(vec![], |s| s.reason().into_bytes());
|
||||||
self.status.set(status.code());
|
let status_code = status.as_ref().map_or(0, |s| s.code());
|
||||||
|
|
||||||
|
*self.status_text.borrow_mut() = ByteString::new(status_text);
|
||||||
|
self.status.set(status_code);
|
||||||
match headers {
|
match headers {
|
||||||
Some(ref h) => {
|
Some(ref h) => {
|
||||||
*self.response_headers.borrow_mut() = h.clone();
|
*self.response_headers.borrow_mut() = h.clone();
|
||||||
|
|
|
@ -1,14 +0,0 @@
|
||||||
[send-redirect-bogus.htm]
|
|
||||||
type: testharness
|
|
||||||
[XMLHttpRequest: send() - Redirects (bogus Location header) (302: http://example.not)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[XMLHttpRequest: send() - Redirects (bogus Location header) (302: mailto:someone@example.org)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[XMLHttpRequest: send() - Redirects (bogus Location header) (303: http://example.not)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[XMLHttpRequest: send() - Redirects (bogus Location header) (303: foobar:someone@example.org)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue