Skip to content
Permalink
Browse files

Add useful debug output for HTTP response and image cache.

  • Loading branch information...
jdm committed Oct 4, 2019
1 parent 734cf9e commit a241232c2b72480bc6c6133dae1c66774140a410
@@ -1333,6 +1333,7 @@ fn http_network_fetch(
res.status(),
res.status().canonical_reason().unwrap_or("").into(),
));
debug!("got {:?} response for {:?}", res.status(), request.url());
response.raw_status = Some((
res.status().as_u16(),
res.status().canonical_reason().unwrap_or("").into(),
@@ -1387,6 +1388,8 @@ fn http_network_fetch(
let done_sender3 = done_sender.clone();
let timing_ptr2 = context.timing.clone();
let timing_ptr3 = context.timing.clone();
let url1 = request.url();
let url2 = url1.clone();
HANDLE.lock().unwrap().spawn(
res.into_body()
.map_err(|_| ())
@@ -1404,6 +1407,7 @@ fn http_network_fetch(
future::ok(res_body)
})
.and_then(move |res_body| {
debug!("successfully finished response for {:?}", url1);
let mut body = res_body.lock().unwrap();
let completed_body = match *body {
ResponseBody::Receiving(ref mut body) => mem::replace(body, vec![]),
@@ -1418,6 +1422,7 @@ fn http_network_fetch(
future::ok(())
})
.map_err(move |_| {
debug!("finished response for {:?} with error", url2);
let mut body = res_body2.lock().unwrap();
let completed_body = match *body {
ResponseBody::Receiving(ref mut body) => mem::replace(body, vec![]),
@@ -530,6 +530,7 @@ impl ImageCache for ImageCacheImpl {
(FetchResponseMsg::ProcessRequestBody, _) |
(FetchResponseMsg::ProcessRequestEOF, _) => return,
(FetchResponseMsg::ProcessResponse(response), _) => {
debug!("Received {:?} for {:?}", response.as_ref().map(|_| ()), id);
let mut store = self.store.lock().unwrap();
let pending_load = store.pending_loads.get_by_key_mut(&id).unwrap();
let (cors_status, metadata) = match response {
@@ -186,6 +186,7 @@ impl FetchResponseListener for ImageContext {
fn process_request_eof(&mut self) {}

fn process_response(&mut self, metadata: Result<FetchMetadata, NetworkError>) {
debug!("got {:?} for {:?}", metadata.as_ref().map(|_| ()), self.url);
self.image_cache
.notify_pending_response(self.id, FetchResponseMsg::ProcessResponse(metadata.clone()));

@@ -180,7 +180,8 @@ impl fmt::Display for ServoUrl {
impl fmt::Debug for ServoUrl {
fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
if self.0.as_str().len() > 40 {
let hasher = DefaultHasher::new();
let mut hasher = DefaultHasher::new();
hasher.write(self.0.as_str().as_bytes());
let truncated: String = self.0.as_str().chars().take(40).collect();
let result = format!("{}... ({:x})", truncated, hasher.finish());
return result.fmt(formatter);

0 comments on commit a241232

Please sign in to comment.
You can’t perform that action at this time.