Skip to content

Feature request: ability to check if the connection is still alive #2017

Closed
@ngxson

Description

@ngxson

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 has Stream &strm in its scope, so we can pass it to Server::dispatch_request
  • Then, we can expose it inside Handler, by wrapping it inside a function is_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!

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions