Implement the Fetch method

This commit is contained in:
Jeena Lee 2016-09-06 10:54:06 -07:00
parent a03a5e814a
commit 3216009731
213 changed files with 1208 additions and 1719 deletions

View file

@ -18,7 +18,9 @@ use dom::headers::{Headers, Guard};
use dom::headers::{is_vchar, is_obs_text};
use dom::promise::Promise;
use dom::xmlhttprequest::Extractable;
use hyper::header::Headers as HyperHeaders;
use hyper::status::StatusCode;
use hyper_serde::Serde;
use net_traits::response::{ResponseBody as NetTraitsResponseBody};
use std::mem;
use std::rc::Rc;
@ -344,3 +346,24 @@ impl ResponseMethods for Response {
fn serialize_without_fragment(url: &Url) -> &str {
&url[..Position::AfterQuery]
}
impl Response {
pub fn set_type(&self, new_response_type: DOMResponseType) {
*self.response_type.borrow_mut() = new_response_type;
}
pub fn set_headers(&self, option_hyper_headers: Option<Serde<HyperHeaders>>) {
self.Headers().set_headers(match option_hyper_headers {
Some(hyper_headers) => hyper_headers.into_inner(),
None => HyperHeaders::new(),
});
}
pub fn set_raw_status(&self, status: Option<(u16, Vec<u8>)>) {
*self.raw_status.borrow_mut() = status;
}
pub fn set_final_url(&self, final_url: Url) {
*self.url.borrow_mut() = Some(final_url);
}
}