You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
How can I detect from a handler that the underlying request is canceled? Other server implementations such as hyper drop the handle future on request cancelation, but it seems async-h1 doesn't.
How to reproduce:
structDropGuard;implDropforDropGuard{fndrop(&mutself){println!("dropped!")}}// Take a TCP stream, and convert it into sequential HTTP request / response pairs.asyncfnaccept(stream:TcpStream) -> http_types::Result<()>{println!("starting new connection from {}", stream.peer_addr()?);
async_h1::accept(stream.clone(), |_req| asyncmove{let g = DropGuard;println!("got request!");
async_std::task::sleep(std::time::Duration::from_secs(3)).await;println!("sending response!");letmut res = Response::new(StatusCode::Ok);
res.insert_header("Content-Type","text/plain");
res.set_body("Hello world");Ok(res)}).await?;Ok(())}
In a terminal, curl localhost:8080 and ctrl+C before the 3 second timeout.
I am serving big files (movies) with tide and get a lot of errors due to cancellation of the video playing on client side.
I am wondering wether this should be handled at async-h1 level or tide level (for instance).
When the handler is done reading the request body, start a "background read"
If the background read completes with EOF or with error, the request has been canceled.
If the background read completes with some data, this is part of the next (probably pipelined) request. That data needs to be kept around for decoding it.
How can I detect from a handler that the underlying request is canceled? Other server implementations such as
hyper
drop the handle future on request cancelation, but it seemsasync-h1
doesn't.How to reproduce:
In a terminal,
curl localhost:8080
and ctrl+C before the 3 second timeout.What you see is:
what you would see if the future was dropped is:
The text was updated successfully, but these errors were encountered: