ark::comms::HttpClientState

Defined in header “ark/comms/http_server.hh”.


Represents internal state for an HTTP client. This is just used within the server itself to manage the clients.

Methods

  • void write_response(const HttpResponse & response, std::chrono::nanoseconds timeout)
    Writes the given response over the this state. Will try to write for the timeout period if the timeout period is exhausted, the socket is closed early.

  • HttpRequest parse_request()
    Returns the active HTTP request, assuming it is fully populated and parsable.

  • bool payload_complete()
    Returns true if the payload has been fully populated, or false otherwise.

  • void clean()
    Cleans out the state; prepares it for destruction. Cleans out all the socket and callback state to avoid loops.

Variables

  • HttpRequestParser request
    Tracks the incoming request.

  • SocketPtr socket
    For convenience, stores a reference to the socket that this client is managing.

  • HttpClientWriterPtr writer
    For streaming connection, stores a reference to the socket writer.

  • NetworkAddress address
    A cached copy of the address of this client.

  • StreamingCallbacks streaming_callbacks
    For streaming connection, callbacks to be invoked when a streaming request changes states.

  • std::optional< HttpRequest > parsed_headers
    The parsed HTTP request headers for this state, if any.

  • std::atomic< bool > detached= false
    Indicates if this client state is detached or “handled”. This will be true if we are either in websocket mode, or asynchronously being handled.

  • std::atomic< bool > closed= false
    Indicates if we are ‘closed’ or not. A closed socket will be cleaned up asynchronously, so we can be sure to only drop the descriptor to socket when necessary.

  • size_t window_size= 4096
    Window size for reading; increases if we seem to be reading a lot of content.

  • std::function< void()> close{}
    Closes this HTTP client state; the underlying socket is not yet closed. Invoke this to safely manage the socket state with respect to the rest of the HTTP server.

  • std::optional< HttpClientOndiskRequestPayload > payload_content_path
    If set, the request payload is actually stored in this file, rather than in-memory.