mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
Add aborted flag to response, set when fetch is aborted
This commit is contained in:
parent
7249fd6bd8
commit
6f59b152f1
3 changed files with 21 additions and 8 deletions
|
@ -1088,6 +1088,9 @@ fn http_network_fetch(request: &Request,
|
|||
let meta_status = meta.status.clone();
|
||||
let meta_headers = meta.headers.clone();
|
||||
let cancellation_listener = context.cancellation_listener.clone();
|
||||
if cancellation_listener.lock().unwrap().cancelled() {
|
||||
return Response::network_error(NetworkError::Internal("Fetch aborted".into()))
|
||||
}
|
||||
thread::Builder::new().name(format!("fetch worker thread")).spawn(move || {
|
||||
match StreamedResponse::from_http_response(res) {
|
||||
Ok(mut res) => {
|
||||
|
@ -1112,7 +1115,7 @@ fn http_network_fetch(request: &Request,
|
|||
loop {
|
||||
if cancellation_listener.lock().unwrap().cancelled() {
|
||||
*res_body.lock().unwrap() = ResponseBody::Done(vec![]);
|
||||
let _ = done_sender.send(Data::Done);
|
||||
let _ = done_sender.send(Data::Cancelled);
|
||||
return;
|
||||
}
|
||||
match read_block(&mut res) {
|
||||
|
@ -1134,6 +1137,7 @@ fn http_network_fetch(request: &Request,
|
|||
let _ = done_sender.send(Data::Done);
|
||||
break;
|
||||
}
|
||||
Ok(Data::Cancelled) => unreachable!() // read_block doesn't return Data::Cancelled
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue