Refactor http_fetch to reflect the new standard

This commit is contained in:
Keith Yeung 2015-11-11 21:00:25 -08:00
parent 7623e89506
commit 7d3eb72a26
3 changed files with 152 additions and 83 deletions

View file

@ -35,6 +35,8 @@ use ipc_channel::ipc::{self, IpcReceiver, IpcSender};
use msg::constellation_msg::{PipelineId};
use regex::Regex;
use serde::{Deserializer, Serializer};
use std::cell::RefCell;
use std::rc::Rc;
use std::thread;
use url::Url;
use util::mem::HeapSizeOf;
@ -55,7 +57,8 @@ pub enum ResponseType {
CORS,
Default,
Error,
Opaque
Opaque,
OpaqueRedirect
}
/// [Response termination reason](https://fetch.spec.whatwg.org/#concept-response-termination-reason)
@ -87,13 +90,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 {
@ -102,6 +106,7 @@ impl Response {
response_type: ResponseType::Error,
termination_reason: None,
url: None,
url_list: vec![],
status: None,
headers: Headers::new(),
body: ResponseBody::Empty,