12 #include "../OSSupport/Network.h"
51 void Send(
const void * a_Data,
size_t a_Size);
85 virtual void OnReceivedData(
const char * a_Data,
size_t a_Size)
override;
91 virtual void OnError(
int a_ErrorCode,
const AString & a_ErrorMsg)
override;
98 virtual void OnBodyData(
const void * a_Data,
size_t a_Size)
override;
103 virtual void SendData(
const void * a_Data,
size_t a_Size);
109 SendData(a_Data.data(), a_Data.size());
std::vector< cHTTPServerConnection * > cHTTPServerConnections
std::shared_ptr< cTCPLink > cTCPLinkPtr
Stores outgoing response headers and serializes them to an HTTP data stream.
Provides storage for an incoming HTTP request.
std::map< AString, AString > cNameValueMap
virtual void OnFirstLine(const AString &a_FirstLine) override
Called when the first line of the request or response is fully parsed.
cTCPLinkPtr m_Link
The network link attached to this connection.
cHTTPServerConnection(cHTTPServer &a_HTTPServer)
Creates a new instance, connected to the specified HTTP server instance.
virtual void OnHeadersFinished(void) override
Called when all the headers have been parsed.
void Terminate(void)
Terminates the connection; finishes any request being currently processed.
virtual void OnBodyFinished(void) override
Called when the entire body has been reported by OnBodyData().
void SendData(const AString &a_Data)
Sends the raw data over the link.
virtual void OnBodyData(const void *a_Data, size_t a_Size) override
Called for each chunk of the incoming body data.
cHTTPMessageParser m_Parser
The parser responsible for reading the requests.
void Send(const AString &a_Data)
Sends the data as the response (may be called multiple times)
void SendNeedAuth(const AString &a_Realm)
Sends the "401 unauthorized" reply together with instructions on authorizing, using the specified rea...
virtual ~cHTTPServerConnection() override
virtual void OnRemoteClosed(void) override
The socket has been closed for any reason.
cHTTPServer & m_HTTPServer
The parent webserver that is to be notified of events on this connection.
virtual void OnHeaderLine(const AString &a_Key, const AString &a_Value) override
Called when a single header line is parsed.
void FinishResponse(void)
Indicates that the current response is finished, gets ready for receiving another request (HTTP 1....
virtual void OnError(int a_ErrorCode, const AString &a_ErrorMsg) override
An error has occurred on the socket.
virtual void OnReceivedData(const char *a_Data, size_t a_Size) override
Data is received from the client.
std::unique_ptr< cHTTPIncomingRequest > m_CurrentRequest
The request being currently received Valid only between having parsed the headers and finishing recei...
void SendStatusAndReason(int a_StatusCode, const AString &a_Reason)
Sends HTTP status code together with a_Reason (used for HTTP errors).
virtual void OnLinkCreated(cTCPLinkPtr a_Link) override
The link instance has been created, remember it.
void Send(const cHTTPOutgoingResponse &a_Response)
Sends the headers contained in a_Response.
virtual void SendData(const void *a_Data, size_t a_Size)
Called to send raw data over the link.