diff options
Diffstat (limited to 'components/net/fetch/methods.rs')
-rw-r--r-- | components/net/fetch/methods.rs | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/components/net/fetch/methods.rs b/components/net/fetch/methods.rs index 28cf08382bc..f2e6b80d0a9 100644 --- a/components/net/fetch/methods.rs +++ b/components/net/fetch/methods.rs @@ -17,10 +17,12 @@ use hyper::mime::{Attr, Mime, SubLevel, TopLevel, Value}; use hyper::status::StatusCode; use net_traits::request::{CacheMode, Context, ContextFrameType, CredentialsMode}; use net_traits::request::{RedirectMode, Referer, Request, RequestMode, ResponseTainting}; -use net_traits::response::{CacheState, HttpsState, Response, ResponseType, TerminationReason}; +use net_traits::response::{CacheState, HttpsState, TerminationReason}; +use net_traits::response::{Response, ResponseBody, ResponseType}; use net_traits::{AsyncFetchListener, Metadata}; use resource_thread::CancellationListener; use std::ascii::AsciiExt; +use std::io::Read; use std::rc::Rc; use std::str::FromStr; use std::thread; @@ -163,7 +165,8 @@ fn http_fetch(request: Rc<Request>, // Step 3 if !request.skip_service_worker.get() && !request.is_service_worker_global_scope { - // TODO: Substep 1 (handle fetch unimplemented) + // Substep 1 + // TODO (handle fetch unimplemented) if let Some(ref res) = response { @@ -617,11 +620,15 @@ fn http_network_fetch(request: Rc<Request>, let mut response = Response::new(); match wrapped_response { - Ok(res) => { + Ok(mut res) => { // is it okay for res.version to be unused? response.url = Some(res.response.url.clone()); response.status = Some(res.response.status); response.headers = res.response.headers.clone(); + + let mut body = vec![]; + res.response.read_to_end(&mut body); + response.body = ResponseBody::Done(body); }, Err(e) => response.termination_reason = Some(TerminationReason::Fatal) @@ -633,7 +640,7 @@ fn http_network_fetch(request: Rc<Request>, // Substep 2 // TODO how can I tell if response was retrieved over HTTPS? - // TODO: Servo needs to decide what ciphers are to be treated as "deprecated" + // TODO Servo needs to decide what ciphers are to be treated as "deprecated" response.https_state = HttpsState::None; // TODO how do I read request? @@ -656,9 +663,14 @@ fn http_network_fetch(request: Rc<Request>, *response.url_list.borrow_mut() = request.url_list.borrow().clone(); // Step 7 + // TODO this step isn't possible yet // Step 8 + if Response::is_network_error(&response) && request.cache_mode.get() == CacheMode::NoStore { + // TODO update response in the HTTP cache for request + } + // TODO these steps aren't possible yet // Step 9 // Substep 1 // Substep 2 |