Skip to content

Commit

Permalink
Simplify obtain_response() a little.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ms2ger committed Nov 24, 2016
1 parent 47fa025 commit 53856bf
Showing 1 changed file with 14 additions and 19 deletions.
33 changes: 14 additions & 19 deletions components/net/http_loader.rs
Expand Up @@ -479,10 +479,7 @@ fn obtain_response(request_factory: &NetworkHttpRequestFactory,
is_xhr: bool)
-> Result<(WrappedHttpResponse, Option<ChromeToDevtoolsControlMsg>), LoadError> {
let null_data = None;
let response;
let connection_url = replace_hosts(&url);
let mut msg;


// loop trying connections in connection pool
// they may have grown stale (disconnected), in which case we'll get
Expand Down Expand Up @@ -533,7 +530,19 @@ fn obtain_response(request_factory: &NetworkHttpRequestFactory,

let send_end = precise_time_ms();

msg = if let Some(request_id) = request_id {
let response = match maybe_response {
Ok(r) => r,
Err(e) => {
if let LoadErrorType::ConnectionAborted { reason } = e.error {
debug!("connection aborted ({:?}), possibly stale, trying new connection", reason);
continue;
} else {
return Err(e)
}
},
};

let msg = if let Some(request_id) = request_id {
if let Some(pipeline_id) = *pipeline_id {
Some(prepare_devtools_request(
request_id.into(),
Expand All @@ -549,23 +558,9 @@ fn obtain_response(request_factory: &NetworkHttpRequestFactory,
None
};

response = match maybe_response {
Ok(r) => r,
Err(e) => {
if let LoadErrorType::ConnectionAborted { reason } = e.error {
debug!("connection aborted ({:?}), possibly stale, trying new connection", reason);
continue;
} else {
return Err(e)
}
},
};

// if no ConnectionAborted, break the loop
break;
return Ok((response, msg));
}

Ok((response, msg))
}

// FIXME: This incredibly hacky. Make it more robust, and at least test it.
Expand Down

0 comments on commit 53856bf

Please sign in to comment.