diff options
author | Mattes D <github@xoft.cz> | 2015-01-30 08:40:45 +0100 |
---|---|---|
committer | Mattes D <github@xoft.cz> | 2015-01-30 08:40:45 +0100 |
commit | fd49e34e331fc716c48ea1228f24954e9b8b5304 (patch) | |
tree | 8d19b61fb5b3052b870ccc9ac956c5069d12dc74 /src/HTTPServer/HTTPServer.h | |
parent | Updated PolarSSL. (diff) | |
parent | Fixed listening ports not closed on cServerHandle::Close. (diff) | |
download | cuberite-fd49e34e331fc716c48ea1228f24954e9b8b5304.tar cuberite-fd49e34e331fc716c48ea1228f24954e9b8b5304.tar.gz cuberite-fd49e34e331fc716c48ea1228f24954e9b8b5304.tar.bz2 cuberite-fd49e34e331fc716c48ea1228f24954e9b8b5304.tar.lz cuberite-fd49e34e331fc716c48ea1228f24954e9b8b5304.tar.xz cuberite-fd49e34e331fc716c48ea1228f24954e9b8b5304.tar.zst cuberite-fd49e34e331fc716c48ea1228f24954e9b8b5304.zip |
Diffstat (limited to '')
-rw-r--r-- | src/HTTPServer/HTTPServer.h | 52 |
1 files changed, 20 insertions, 32 deletions
diff --git a/src/HTTPServer/HTTPServer.h b/src/HTTPServer/HTTPServer.h index 73d4cbdd0..d626fb475 100644 --- a/src/HTTPServer/HTTPServer.h +++ b/src/HTTPServer/HTTPServer.h @@ -9,8 +9,7 @@ #pragma once -#include "../OSSupport/ListenThread.h" -#include "../OSSupport/SocketThreads.h" +#include "../OSSupport/Network.h" #include "../IniFile.h" #include "PolarSSL++/RsaPrivateKey.h" #include "PolarSSL++/CryptoKey.h" @@ -33,8 +32,7 @@ typedef std::vector<cHTTPConnection *> cHTTPConnections; -class cHTTPServer : - public cListenThread::cCallback +class cHTTPServer { public: class cCallbacks @@ -42,44 +40,39 @@ public: public: virtual ~cCallbacks() {} - /** Called when a new request arrives over a connection and its headers have been parsed. - The request body needn't have arrived yet. - */ + /** Called when a new request arrives over a connection and all its headers have been parsed. + The request body needn't have arrived yet. */ virtual void OnRequestBegun(cHTTPConnection & a_Connection, cHTTPRequest & a_Request) = 0; /** Called when another part of request body has arrived. May be called multiple times for a single request. */ virtual void OnRequestBody(cHTTPConnection & a_Connection, cHTTPRequest & a_Request, const char * a_Data, size_t a_Size) = 0; - /// Called when the request body has been fully received in previous calls to OnRequestBody() + /** Called when the request body has been fully received in previous calls to OnRequestBody() */ virtual void OnRequestFinished(cHTTPConnection & a_Connection, cHTTPRequest & a_Request) = 0; } ; cHTTPServer(void); virtual ~cHTTPServer(); - /// Initializes the server on the specified ports - bool Initialize(const AString & a_PortsIPv4, const AString & a_PortsIPv6); + /** Initializes the server - reads the cert files etc. */ + bool Initialize(void); - /// Starts the server and assigns the callbacks to use for incoming requests - bool Start(cCallbacks & a_Callbacks); + /** Starts the server and assigns the callbacks to use for incoming requests */ + bool Start(cCallbacks & a_Callbacks, const AStringVector & a_Ports); - /// Stops the server, drops all current connections + /** Stops the server, drops all current connections */ void Stop(void); protected: friend class cHTTPConnection; friend class cSslHTTPConnection; + friend class cHTTPServerListenCallbacks; - cListenThread m_ListenThreadIPv4; - cListenThread m_ListenThreadIPv6; + /** The cNetwork API handle for the listening socket. */ + cServerHandlePtrs m_ServerHandles; - cSocketThreads m_SocketThreads; - - cCriticalSection m_CSConnections; - cHTTPConnections m_Connections; ///< All the connections that are currently being serviced - - /// The callbacks to call for various events + /** The callbacks to call for various events */ cCallbacks * m_Callbacks; /** The server certificate to use for the SSL connections */ @@ -89,23 +82,18 @@ protected: cCryptoKeyPtr m_CertPrivKey; - // cListenThread::cCallback overrides: - virtual void OnConnectionAccepted(cSocket & a_Socket) override; - - /// Called by cHTTPConnection to close the connection (presumably due to an error) - void CloseConnection(cHTTPConnection & a_Connection); - - /// Called by cHTTPConnection to notify SocketThreads that there's data to be sent for the connection - void NotifyConnectionWrite(cHTTPConnection & a_Connection); - - /// Called by cHTTPConnection when it finishes parsing the request header + /** Called by cHTTPServerListenCallbacks when there's a new incoming connection. + Returns the connection instance to be used as the cTCPLink callbacks. */ + cTCPLink::cCallbacksPtr OnIncomingConnection(const AString & a_RemoteIPAddress, UInt16 a_RemotePort); + + /** Called by cHTTPConnection when it finishes parsing the request header */ void NewRequest(cHTTPConnection & a_Connection, cHTTPRequest & a_Request); /** Called by cHTTPConenction when it receives more data for the request body. May be called multiple times for a single request. */ void RequestBody(cHTTPConnection & a_Connection, cHTTPRequest & a_Request, const char * a_Data, size_t a_Size); - /// Called by cHTTPConnection when it detects that the request has finished (all of its body has been received) + /** Called by cHTTPConnection when it detects that the request has finished (all of its body has been received) */ void RequestFinished(cHTTPConnection & a_Connection, cHTTPRequest & a_Request); } ; |