Description
Following up #1956, I would like to discuss more about the ability to add a method to check if the socket is still alive. This can be useful to cancel the underlay processing for a request, as described in this issue: ggml-org/llama.cpp#9273
Currently, one way to do is to use set_chunked_content_provider
, but the problem is that we cannot change the HTTP status code once we're already inside the callback function.
Therefore, I propose 2 solutions here:
My first suggestion is to add something like set_async_response
, which works like set_chunked_content_provider
but send out the whole response, instead of only the body.
Second suggestion is to add is_alive()
to the Handler
:
Server::routing
already hasStream &strm
in its scope, so we can pass it toServer::dispatch_request
- Then, we can expose it inside
Handler
, by wrapping it inside a functionis_alive()
. I'm not sure how it should look like, but that's the idea
Happy do discuss more to see what's the best way to implement this. Thank you!