mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Simplify obtain_response() a little.
This commit is contained in:
parent
47fa025e89
commit
53856bf312
1 changed files with 14 additions and 19 deletions
|
@ -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
|
||||
|
@ -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(),
|
||||
|
@ -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.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue