From a1fd2353471c00385bdb0636b45e6d184a525118 Mon Sep 17 00:00:00 2001 From: Sam Gibson Date: Fri, 28 Aug 2015 09:02:33 +1000 Subject: [PATCH] Moves devtools request msg logic to where the request is sent --- components/net/http_loader.rs | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/components/net/http_loader.rs b/components/net/http_loader.rs index 90cfb25862d..2c8a0470c3d 100644 --- a/components/net/http_loader.rs +++ b/components/net/http_loader.rs @@ -517,26 +517,32 @@ pub fn load(load_data: LoadData, // // https://tools.ietf.org/html/rfc7231#section-6.4 let is_redirected_request = iters != 1; + let request_id = uuid::Uuid::new_v4().to_simple_string(); let response = match load_data.data { Some(ref data) if !is_redirected_request => { req.headers_mut().set(ContentLength(data.len() as u64)); + + // TODO: Do this only if load_data has some pipeline_id, and send the pipeline_id + // in the message + send_request_to_devtools( + devtools_chan.clone(), request_id.clone(), url.clone(), + method.clone(), load_data.headers.clone(), + load_data.data.clone() + ); + try!(req.send(&load_data.data)) } _ => { + send_request_to_devtools( + devtools_chan.clone(), request_id.clone(), url.clone(), + method.clone(), load_data.headers.clone(), + None + ); + try!(req.send(&None)) } }; - let request_id = uuid::Uuid::new_v4().to_simple_string(); - - // TODO: Do this only if load_data has some pipeline_id, and send the pipeline_id in the - // message - send_request_to_devtools( - devtools_chan.clone(), request_id.clone(), url.clone(), - method.clone(), load_data.headers.clone(), - if is_redirected_request { None } else { load_data.data.clone() } - ); - info!("got HTTP response {}, headers:", response.status()); if log_enabled!(log::LogLevel::Info) { for header in response.headers().iter() {