Auto merge of #8516 - KiChjang:http-fetch-refactor, r=jdm

Refactor http_fetch to reflect the new standard

Partial #4576. The spec is really getting funky now - it's depending more and more on the DOM objects (e.g. prompting the user for authentication using a `Window` object). I think we can just pass in username and password as properties of the `Request` struct though.

I've also added in the async version for http_request.

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/8516)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2015-11-27 11:39:32 +05:30
commit a515fe320b
3 changed files with 152 additions and 83 deletions

View file

@ -32,6 +32,8 @@ use hyper::status::StatusCode;
use ipc_channel::ipc::{self, IpcReceiver, IpcSender};
use msg::constellation_msg::{PipelineId};
use serde::{Deserializer, Serializer};
use std::cell::RefCell;
use std::rc::Rc;
use std::thread;
use url::Url;
use util::mem::HeapSizeOf;
@ -48,7 +50,8 @@ pub enum ResponseType {
CORS,
Default,
Error,
Opaque
Opaque,
OpaqueRedirect
}
/// [Response termination reason](https://fetch.spec.whatwg.org/#concept-response-termination-reason)
@ -80,13 +83,14 @@ pub struct Response {
pub response_type: ResponseType,
pub termination_reason: Option<TerminationReason>,
pub url: Option<Url>,
pub url_list: Vec<Url>,
/// `None` can be considered a StatusCode of `0`.
pub status: Option<StatusCode>,
pub headers: Headers,
pub body: ResponseBody,
/// [Internal response](https://fetch.spec.whatwg.org/#concept-internal-response), only used if the Response
/// is a filtered response
pub internal_response: Option<Box<Response>>,
pub internal_response: Option<Rc<RefCell<Response>>>,
}
impl Response {
@ -95,6 +99,7 @@ impl Response {
response_type: ResponseType::Error,
termination_reason: None,
url: None,
url_list: vec![],
status: None,
headers: Headers::new(),
body: ResponseBody::Empty,