Cuberite
A lightweight, fast and extensible game server for Minecraft
|
#include <HTTPServerConnection.h>
Public Member Functions | |
cHTTPServerConnection (cHTTPServer &a_HTTPServer) | |
Creates a new instance, connected to the specified HTTP server instance. More... | |
void | FinishResponse (void) |
Indicates that the current response is finished, gets ready for receiving another request (HTTP 1.1 keepalive). More... | |
void | Send (const AString &a_Data) |
Sends the data as the response (may be called multiple times) More... | |
void | Send (const cHTTPOutgoingResponse &a_Response) |
Sends the headers contained in a_Response. More... | |
void | Send (const void *a_Data, size_t a_Size) |
Sends the data as the response (may be called multiple times) More... | |
void | SendNeedAuth (const AString &a_Realm) |
Sends the "401 unauthorized" reply together with instructions on authorizing, using the specified realm. More... | |
void | SendStatusAndReason (int a_StatusCode, const AString &a_Reason) |
Sends HTTP status code together with a_Reason (used for HTTP errors). More... | |
void | Terminate (void) |
Terminates the connection; finishes any request being currently processed. More... | |
virtual | ~cHTTPServerConnection () override |
Public Member Functions inherited from cTCPLink::cCallbacks | |
virtual void | OnTlsHandshakeCompleted (void) |
Called when the TLS handshake has been completed and communication can continue regularly. More... | |
virtual | ~cCallbacks () |
Public Member Functions inherited from cHTTPMessageParser::cCallbacks | |
virtual | ~cCallbacks () |
Protected Types | |
typedef std::map< AString, AString > | cNameValueMap |
Protected Member Functions | |
virtual void | OnBodyData (const void *a_Data, size_t a_Size) override |
Called for each chunk of the incoming body data. More... | |
virtual void | OnBodyFinished (void) override |
Called when the entire body has been reported by OnBodyData(). More... | |
virtual void | OnError (const AString &a_ErrorDescription) override |
Called when an error has occured while parsing. More... | |
virtual void | OnError (int a_ErrorCode, const AString &a_ErrorMsg) override |
An error has occurred on the socket. More... | |
virtual void | OnFirstLine (const AString &a_FirstLine) override |
Called when the first line of the request or response is fully parsed. More... | |
virtual void | OnHeaderLine (const AString &a_Key, const AString &a_Value) override |
Called when a single header line is parsed. More... | |
virtual void | OnHeadersFinished (void) override |
Called when all the headers have been parsed. More... | |
virtual void | OnLinkCreated (cTCPLinkPtr a_Link) override |
The link instance has been created, remember it. More... | |
virtual void | OnReceivedData (const char *a_Data, size_t a_Size) override |
Data is received from the client. More... | |
virtual void | OnRemoteClosed (void) override |
The socket has been closed for any reason. More... | |
void | SendData (const AString &a_Data) |
Sends the raw data over the link. More... | |
virtual void | SendData (const void *a_Data, size_t a_Size) |
Called to send raw data over the link. More... | |
Protected Attributes | |
std::unique_ptr< cHTTPIncomingRequest > | m_CurrentRequest |
The request being currently received Valid only between having parsed the headers and finishing receiving the body. More... | |
cHTTPServer & | m_HTTPServer |
The parent webserver that is to be notified of events on this connection. More... | |
cTCPLinkPtr | m_Link |
The network link attached to this connection. More... | |
cHTTPMessageParser | m_Parser |
The parser responsible for reading the requests. More... | |
Definition at line 27 of file HTTPServerConnection.h.
|
protected |
Definition at line 64 of file HTTPServerConnection.h.
cHTTPServerConnection::cHTTPServerConnection | ( | cHTTPServer & | a_HTTPServer | ) |
Creates a new instance, connected to the specified HTTP server instance.
Definition at line 15 of file HTTPServerConnection.cpp.
|
overridevirtualdefault |
void cHTTPServerConnection::FinishResponse | ( | void | ) |
Indicates that the current response is finished, gets ready for receiving another request (HTTP 1.1 keepalive).
Clears the current request (since it's finished by this call).
Definition at line 80 of file HTTPServerConnection.cpp.
|
overrideprotectedvirtual |
Called for each chunk of the incoming body data.
Implements cHTTPMessageParser::cCallbacks.
Definition at line 202 of file HTTPServerConnection.cpp.
|
overrideprotectedvirtual |
Called when the entire body has been reported by OnBodyData().
Implements cHTTPMessageParser::cCallbacks.
Definition at line 215 of file HTTPServerConnection.cpp.
|
overrideprotectedvirtual |
Called when an error has occured while parsing.
Implements cHTTPMessageParser::cCallbacks.
Definition at line 149 of file HTTPServerConnection.cpp.
|
overrideprotectedvirtual |
An error has occurred on the socket.
Implements cTCPLink::cCallbacks.
Definition at line 140 of file HTTPServerConnection.cpp.
|
overrideprotectedvirtual |
Called when the first line of the request or response is fully parsed.
Doesn't check the validity of the line, only extracts the first complete line.
Implements cHTTPMessageParser::cCallbacks.
Definition at line 158 of file HTTPServerConnection.cpp.
|
overrideprotectedvirtual |
Called when a single header line is parsed.
Implements cHTTPMessageParser::cCallbacks.
Definition at line 176 of file HTTPServerConnection.cpp.
|
overrideprotectedvirtual |
Called when all the headers have been parsed.
Implements cHTTPMessageParser::cCallbacks.
Definition at line 189 of file HTTPServerConnection.cpp.
|
overrideprotectedvirtual |
The link instance has been created, remember it.
Implements cTCPLink::cCallbacks.
Definition at line 106 of file HTTPServerConnection.cpp.
|
overrideprotectedvirtual |
Data is received from the client.
Implements cTCPLink::cCallbacks.
Reimplemented in cSslHTTPServerConnection.
Definition at line 116 of file HTTPServerConnection.cpp.
|
overrideprotectedvirtual |
The socket has been closed for any reason.
Implements cTCPLink::cCallbacks.
Definition at line 127 of file HTTPServerConnection.cpp.
|
inline |
Sends the data as the response (may be called multiple times)
Definition at line 54 of file HTTPServerConnection.h.
void cHTTPServerConnection::Send | ( | const cHTTPOutgoingResponse & | a_Response | ) |
Sends the headers contained in a_Response.
Definition at line 55 of file HTTPServerConnection.cpp.
void cHTTPServerConnection::Send | ( | const void * | a_Data, |
size_t | a_Size | ||
) |
Sends the data as the response (may be called multiple times)
Definition at line 67 of file HTTPServerConnection.cpp.
|
inlineprotected |
Sends the raw data over the link.
Descendants may provide data transformations (SSL etc.) via the overridable SendData() function.
Definition at line 107 of file HTTPServerConnection.h.
|
protectedvirtual |
Called to send raw data over the link.
Descendants may provide data transformations (SSL etc.)
Reimplemented in cSslHTTPServerConnection.
Definition at line 232 of file HTTPServerConnection.cpp.
void cHTTPServerConnection::SendNeedAuth | ( | const AString & | a_Realm | ) |
Sends the "401 unauthorized" reply together with instructions on authorizing, using the specified realm.
Clears the current request (since it's finished by this call).
Definition at line 44 of file HTTPServerConnection.cpp.
void cHTTPServerConnection::SendStatusAndReason | ( | int | a_StatusCode, |
const AString & | a_Reason | ||
) |
Sends HTTP status code together with a_Reason (used for HTTP errors).
Sends the a_Reason as the body as well, so that browsers display it. Clears the current request (since it's finished by this call).
Definition at line 31 of file HTTPServerConnection.cpp.
void cHTTPServerConnection::Terminate | ( | void | ) |
Terminates the connection; finishes any request being currently processed.
Definition at line 92 of file HTTPServerConnection.cpp.
|
protected |
The request being currently received Valid only between having parsed the headers and finishing receiving the body.
Definition at line 74 of file HTTPServerConnection.h.
|
protected |
The parent webserver that is to be notified of events on this connection.
Definition at line 67 of file HTTPServerConnection.h.
|
protected |
The network link attached to this connection.
Definition at line 77 of file HTTPServerConnection.h.
|
protected |
The parser responsible for reading the requests.
Definition at line 70 of file HTTPServerConnection.h.