Cute   Learning Hub

  • HttpBroker
  • HttpBroker Class

    class Cute::Server::HttpBroker

    The Cute::Server::HttpBroker allows HTTP handlers to fetch the parsed HttpRequest sent by clients. It also allows HTTP handlers to send the HTTP response back to the client. More...

    Header: #include <HttpBroker>

    Public Functions

    const Cute::Server::HttpRequest &request() const
    void sendResponse(const Cute::Server::HttpResponse &response)

    Detailed Description

    Member Function Documentation

    const Cute::Server::HttpRequest &HttpBroker::request() const

    Returns the HTTP request sent by the client.

    void HttpBroker::sendResponse(const Cute::Server::HttpResponse &response)

    Sends the response back to the client. This method allows the remote object handling the HTTP request to send the response after the slot returns. This way, the remote object can interact with backend services like databases and only send the HTTP response to the client after receiving the response from the backend service.

    After sending the HTTP response to the client, the Cute server calls the deleteLater slot on the remote object. If the HTTP response contains the "Connection: close" header, the Cute server closes the connection after sending the HTTP response to the client. Otherwise, the connection stays open. The Cute server creates a remote object to process every HTTP request received in a connection. The Cute server supports pipelining. Thus, clients can send multiple HTTP requests before receiving any response from the server.