Moves devtools request msg logic to where the request is sent

This commit is contained in:
Sam Gibson 2015-08-28 09:02:33 +10:00
parent 3b8bada5a1
commit a1fd235347

View file

@ -517,26 +517,32 @@ pub fn load<A>(load_data: LoadData,
// //
// https://tools.ietf.org/html/rfc7231#section-6.4 // https://tools.ietf.org/html/rfc7231#section-6.4
let is_redirected_request = iters != 1; let is_redirected_request = iters != 1;
let request_id = uuid::Uuid::new_v4().to_simple_string();
let response = match load_data.data { let response = match load_data.data {
Some(ref data) if !is_redirected_request => { Some(ref data) if !is_redirected_request => {
req.headers_mut().set(ContentLength(data.len() as u64)); req.headers_mut().set(ContentLength(data.len() as u64));
try!(req.send(&load_data.data))
}
_ => {
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
// TODO: Do this only if load_data has some pipeline_id, and send the pipeline_id in the
// message
send_request_to_devtools( send_request_to_devtools(
devtools_chan.clone(), request_id.clone(), url.clone(), devtools_chan.clone(), request_id.clone(), url.clone(),
method.clone(), load_data.headers.clone(), method.clone(), load_data.headers.clone(),
if is_redirected_request { None } else { load_data.data.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))
}
};
info!("got HTTP response {}, headers:", response.status()); info!("got HTTP response {}, headers:", response.status());
if log_enabled!(log::LogLevel::Info) { if log_enabled!(log::LogLevel::Info) {
for header in response.headers().iter() { for header in response.headers().iter() {