summaryrefslogtreecommitdiffstats
path: root/src/HTTPServer
diff options
context:
space:
mode:
Diffstat (limited to 'src/HTTPServer')
-rw-r--r--src/HTTPServer/CMakeLists.txt10
-rw-r--r--src/HTTPServer/HTTPServer.cpp20
-rw-r--r--src/HTTPServer/HTTPServer.h24
-rw-r--r--src/HTTPServer/HTTPServerConnection.cpp (renamed from src/HTTPServer/HTTPConnection.cpp)36
-rw-r--r--src/HTTPServer/HTTPServerConnection.h (renamed from src/HTTPServer/HTTPConnection.h)8
-rw-r--r--src/HTTPServer/SslHTTPServerConnection.cpp (renamed from src/HTTPServer/SslHTTPConnection.cpp)12
-rw-r--r--src/HTTPServer/SslHTTPServerConnection.h (renamed from src/HTTPServer/SslHTTPConnection.h)16
7 files changed, 62 insertions, 64 deletions
diff --git a/src/HTTPServer/CMakeLists.txt b/src/HTTPServer/CMakeLists.txt
index a08a1fcf8..e8026f761 100644
--- a/src/HTTPServer/CMakeLists.txt
+++ b/src/HTTPServer/CMakeLists.txt
@@ -6,31 +6,31 @@ include_directories ("${PROJECT_SOURCE_DIR}/../")
SET (SRCS
EnvelopeParser.cpp
- HTTPConnection.cpp
HTTPFormParser.cpp
HTTPMessage.cpp
HTTPServer.cpp
+ HTTPServerConnection.cpp
MultipartParser.cpp
NameValueParser.cpp
- SslHTTPConnection.cpp
+ SslHTTPServerConnection.cpp
UrlParser.cpp
)
SET (HDRS
EnvelopeParser.h
- HTTPConnection.h
HTTPFormParser.h
HTTPMessage.h
HTTPServer.h
+ HTTPServerConnection.h
MultipartParser.h
NameValueParser.h
- SslHTTPConnection.h
+ SslHTTPServerConnection.h
UrlParser.h
)
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
set_source_files_properties(HTTPServer.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=global-constructors ")
- set_source_files_properties(HTTPConnection.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=switch-enum")
+ set_source_files_properties(HTTPServerConnection.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=switch-enum")
set_source_files_properties(HTTPMessage.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=tautological-compare")
endif()
diff --git a/src/HTTPServer/HTTPServer.cpp b/src/HTTPServer/HTTPServer.cpp
index 814a87fe4..1cdf29bca 100644
--- a/src/HTTPServer/HTTPServer.cpp
+++ b/src/HTTPServer/HTTPServer.cpp
@@ -6,9 +6,9 @@
#include "Globals.h"
#include "HTTPServer.h"
#include "HTTPMessage.h"
-#include "HTTPConnection.h"
+#include "HTTPServerConnection.h"
#include "HTTPFormParser.h"
-#include "SslHTTPConnection.h"
+#include "SslHTTPServerConnection.h"
@@ -28,7 +28,7 @@ class cDebugCallbacks :
public cHTTPServer::cCallbacks,
protected cHTTPFormParser::cCallbacks
{
- virtual void OnRequestBegun(cHTTPConnection & a_Connection, cHTTPRequest & a_Request) override
+ virtual void OnRequestBegun(cHTTPServerConnection & a_Connection, cHTTPRequest & a_Request) override
{
UNUSED(a_Connection);
@@ -39,7 +39,7 @@ class cDebugCallbacks :
}
- virtual void OnRequestBody(cHTTPConnection & a_Connection, cHTTPRequest & a_Request, const char * a_Data, size_t a_Size) override
+ virtual void OnRequestBody(cHTTPServerConnection & a_Connection, cHTTPRequest & a_Request, const char * a_Data, size_t a_Size) override
{
UNUSED(a_Connection);
@@ -51,7 +51,7 @@ class cDebugCallbacks :
}
- virtual void OnRequestFinished(cHTTPConnection & a_Connection, cHTTPRequest & a_Request) override
+ virtual void OnRequestFinished(cHTTPServerConnection & a_Connection, cHTTPRequest & a_Request) override
{
cHTTPFormParser * FormParser = reinterpret_cast<cHTTPFormParser *>(a_Request.GetUserData());
if (FormParser != nullptr)
@@ -268,11 +268,11 @@ cTCPLink::cCallbacksPtr cHTTPServer::OnIncomingConnection(const AString & a_Remo
if (m_Cert.get() != nullptr)
{
- return std::make_shared<cSslHTTPConnection>(*this, m_Cert, m_CertPrivKey);
+ return std::make_shared<cSslHTTPServerConnection>(*this, m_Cert, m_CertPrivKey);
}
else
{
- return std::make_shared<cHTTPConnection>(*this);
+ return std::make_shared<cHTTPServerConnection>(*this);
}
}
@@ -280,7 +280,7 @@ cTCPLink::cCallbacksPtr cHTTPServer::OnIncomingConnection(const AString & a_Remo
-void cHTTPServer::NewRequest(cHTTPConnection & a_Connection, cHTTPRequest & a_Request)
+void cHTTPServer::NewRequest(cHTTPServerConnection & a_Connection, cHTTPRequest & a_Request)
{
m_Callbacks->OnRequestBegun(a_Connection, a_Request);
}
@@ -289,7 +289,7 @@ void cHTTPServer::NewRequest(cHTTPConnection & a_Connection, cHTTPRequest & a_Re
-void cHTTPServer::RequestBody(cHTTPConnection & a_Connection, cHTTPRequest & a_Request, const char * a_Data, size_t a_Size)
+void cHTTPServer::RequestBody(cHTTPServerConnection & a_Connection, cHTTPRequest & a_Request, const char * a_Data, size_t a_Size)
{
m_Callbacks->OnRequestBody(a_Connection, a_Request, a_Data, a_Size);
}
@@ -298,7 +298,7 @@ void cHTTPServer::RequestBody(cHTTPConnection & a_Connection, cHTTPRequest & a_R
-void cHTTPServer::RequestFinished(cHTTPConnection & a_Connection, cHTTPRequest & a_Request)
+void cHTTPServer::RequestFinished(cHTTPServerConnection & a_Connection, cHTTPRequest & a_Request)
{
m_Callbacks->OnRequestFinished(a_Connection, a_Request);
a_Connection.AwaitNextRequest();
diff --git a/src/HTTPServer/HTTPServer.h b/src/HTTPServer/HTTPServer.h
index 2a094b413..2fd4cdcfc 100644
--- a/src/HTTPServer/HTTPServer.h
+++ b/src/HTTPServer/HTTPServer.h
@@ -23,9 +23,7 @@
class cHTTPMessage;
class cHTTPRequest;
class cHTTPResponse;
-class cHTTPConnection;
-
-typedef std::vector<cHTTPConnection *> cHTTPConnections;
+class cHTTPServerConnection;
@@ -42,14 +40,14 @@ public:
/** 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;
+ virtual void OnRequestBegun(cHTTPServerConnection & 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;
+ virtual void OnRequestBody(cHTTPServerConnection & 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() */
- virtual void OnRequestFinished(cHTTPConnection & a_Connection, cHTTPRequest & a_Request) = 0;
+ virtual void OnRequestFinished(cHTTPServerConnection & a_Connection, cHTTPRequest & a_Request) = 0;
} ;
cHTTPServer(void);
@@ -65,8 +63,8 @@ public:
void Stop(void);
protected:
- friend class cHTTPConnection;
- friend class cSslHTTPConnection;
+ friend class cHTTPServerConnection;
+ friend class cSslHTTPServerConnection;
friend class cHTTPServerListenCallbacks;
/** The cNetwork API handle for the listening socket. */
@@ -86,15 +84,15 @@ protected:
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 cHTTPServerConnection when it finishes parsing the request header */
+ void NewRequest(cHTTPServerConnection & 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);
+ void RequestBody(cHTTPServerConnection & 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) */
- void RequestFinished(cHTTPConnection & a_Connection, cHTTPRequest & a_Request);
+ /** Called by cHTTPServerConnection when it detects that the request has finished (all of its body has been received) */
+ void RequestFinished(cHTTPServerConnection & a_Connection, cHTTPRequest & a_Request);
} ;
diff --git a/src/HTTPServer/HTTPConnection.cpp b/src/HTTPServer/HTTPServerConnection.cpp
index 0db154139..3c4acc2d4 100644
--- a/src/HTTPServer/HTTPConnection.cpp
+++ b/src/HTTPServer/HTTPServerConnection.cpp
@@ -1,10 +1,10 @@
// HTTPConnection.cpp
-// Implements the cHTTPConnection class representing a single persistent connection in the HTTP server.
+// Implements the cHTTPServerConnection class representing a single persistent connection in the HTTP server.
#include "Globals.h"
-#include "HTTPConnection.h"
+#include "HTTPServerConnection.h"
#include "HTTPMessage.h"
#include "HTTPServer.h"
@@ -12,7 +12,7 @@
-cHTTPConnection::cHTTPConnection(cHTTPServer & a_HTTPServer) :
+cHTTPServerConnection::cHTTPServerConnection(cHTTPServer & a_HTTPServer) :
m_HTTPServer(a_HTTPServer),
m_State(wcsRecvHeaders),
m_CurrentRequest(nullptr),
@@ -25,7 +25,7 @@ cHTTPConnection::cHTTPConnection(cHTTPServer & a_HTTPServer) :
-cHTTPConnection::~cHTTPConnection()
+cHTTPServerConnection::~cHTTPServerConnection()
{
// LOGD("HTTP: Connection deleting: %p", this);
delete m_CurrentRequest;
@@ -36,7 +36,7 @@ cHTTPConnection::~cHTTPConnection()
-void cHTTPConnection::SendStatusAndReason(int a_StatusCode, const AString & a_Response)
+void cHTTPServerConnection::SendStatusAndReason(int a_StatusCode, const AString & a_Response)
{
SendData(Printf("HTTP/1.1 %d %s\r\n", a_StatusCode, a_Response.c_str()));
SendData(Printf("Content-Length: %u\r\n\r\n", static_cast<unsigned>(a_Response.size())));
@@ -48,7 +48,7 @@ void cHTTPConnection::SendStatusAndReason(int a_StatusCode, const AString & a_Re
-void cHTTPConnection::SendNeedAuth(const AString & a_Realm)
+void cHTTPServerConnection::SendNeedAuth(const AString & a_Realm)
{
SendData(Printf("HTTP/1.1 401 Unauthorized\r\nWWW-Authenticate: Basic realm=\"%s\"\r\nContent-Length: 0\r\n\r\n", a_Realm.c_str()));
m_State = wcsRecvHeaders;
@@ -58,7 +58,7 @@ void cHTTPConnection::SendNeedAuth(const AString & a_Realm)
-void cHTTPConnection::Send(const cHTTPResponse & a_Response)
+void cHTTPServerConnection::Send(const cHTTPResponse & a_Response)
{
ASSERT(m_State == wcsRecvIdle);
AString toSend;
@@ -71,7 +71,7 @@ void cHTTPConnection::Send(const cHTTPResponse & a_Response)
-void cHTTPConnection::Send(const void * a_Data, size_t a_Size)
+void cHTTPServerConnection::Send(const void * a_Data, size_t a_Size)
{
ASSERT(m_State == wcsSendingResp);
// We're sending in Chunked transfer encoding
@@ -84,7 +84,7 @@ void cHTTPConnection::Send(const void * a_Data, size_t a_Size)
-void cHTTPConnection::FinishResponse(void)
+void cHTTPServerConnection::FinishResponse(void)
{
ASSERT(m_State == wcsSendingResp);
SendData("0\r\n\r\n");
@@ -95,7 +95,7 @@ void cHTTPConnection::FinishResponse(void)
-void cHTTPConnection::AwaitNextRequest(void)
+void cHTTPServerConnection::AwaitNextRequest(void)
{
switch (m_State)
{
@@ -133,7 +133,7 @@ void cHTTPConnection::AwaitNextRequest(void)
-void cHTTPConnection::Terminate(void)
+void cHTTPServerConnection::Terminate(void)
{
if (m_CurrentRequest != nullptr)
{
@@ -146,7 +146,7 @@ void cHTTPConnection::Terminate(void)
-void cHTTPConnection::OnLinkCreated(cTCPLinkPtr a_Link)
+void cHTTPServerConnection::OnLinkCreated(cTCPLinkPtr a_Link)
{
ASSERT(m_Link == nullptr);
m_Link = a_Link;
@@ -156,7 +156,7 @@ void cHTTPConnection::OnLinkCreated(cTCPLinkPtr a_Link)
-void cHTTPConnection::OnReceivedData(const char * a_Data, size_t a_Size)
+void cHTTPServerConnection::OnReceivedData(const char * a_Data, size_t a_Size)
{
ASSERT(m_Link != nullptr);
@@ -198,12 +198,12 @@ void cHTTPConnection::OnReceivedData(const char * a_Data, size_t a_Size)
// Process the rest of the incoming data into the request body:
if (a_Size > BytesConsumed)
{
- cHTTPConnection::OnReceivedData(a_Data + BytesConsumed, a_Size - BytesConsumed);
+ cHTTPServerConnection::OnReceivedData(a_Data + BytesConsumed, a_Size - BytesConsumed);
return;
}
else
{
- cHTTPConnection::OnReceivedData("", 0); // If the request has zero body length, let it be processed right-away
+ cHTTPServerConnection::OnReceivedData("", 0); // If the request has zero body length, let it be processed right-away
return;
}
}
@@ -246,7 +246,7 @@ void cHTTPConnection::OnReceivedData(const char * a_Data, size_t a_Size)
-void cHTTPConnection::OnRemoteClosed(void)
+void cHTTPServerConnection::OnRemoteClosed(void)
{
if (m_CurrentRequest != nullptr)
{
@@ -260,7 +260,7 @@ void cHTTPConnection::OnRemoteClosed(void)
-void cHTTPConnection::OnError(int a_ErrorCode, const AString & a_ErrorMsg)
+void cHTTPServerConnection::OnError(int a_ErrorCode, const AString & a_ErrorMsg)
{
OnRemoteClosed();
}
@@ -268,7 +268,7 @@ void cHTTPConnection::OnError(int a_ErrorCode, const AString & a_ErrorMsg)
-void cHTTPConnection::SendData(const void * a_Data, size_t a_Size)
+void cHTTPServerConnection::SendData(const void * a_Data, size_t a_Size)
{
m_Link->Send(a_Data, a_Size);
}
diff --git a/src/HTTPServer/HTTPConnection.h b/src/HTTPServer/HTTPServerConnection.h
index 414075411..d63cc7395 100644
--- a/src/HTTPServer/HTTPConnection.h
+++ b/src/HTTPServer/HTTPServerConnection.h
@@ -24,7 +24,7 @@ class cHTTPRequest;
-class cHTTPConnection :
+class cHTTPServerConnection :
public cTCPLink::cCallbacks
{
public:
@@ -38,8 +38,8 @@ public:
wcsInvalid, ///< The request was malformed, the connection is closing
} ;
- cHTTPConnection(cHTTPServer & a_HTTPServer);
- virtual ~cHTTPConnection();
+ cHTTPServerConnection(cHTTPServer & a_HTTPServer);
+ virtual ~cHTTPServerConnection();
/** 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. */
@@ -116,7 +116,7 @@ protected:
}
} ;
-typedef std::vector<cHTTPConnection *> cHTTPConnections;
+typedef std::vector<cHTTPServerConnection *> cHTTPServerConnections;
diff --git a/src/HTTPServer/SslHTTPConnection.cpp b/src/HTTPServer/SslHTTPServerConnection.cpp
index 1cbe02312..547e6de3a 100644
--- a/src/HTTPServer/SslHTTPConnection.cpp
+++ b/src/HTTPServer/SslHTTPServerConnection.cpp
@@ -1,17 +1,17 @@
// SslHTTPConnection.cpp
-// Implements the cSslHTTPConnection class representing a HTTP connection made over a SSL link
+// Implements the cSslHTTPServerConnection class representing a HTTP connection made over a SSL link
#include "Globals.h"
-#include "SslHTTPConnection.h"
+#include "SslHTTPServerConnection.h"
#include "HTTPServer.h"
-cSslHTTPConnection::cSslHTTPConnection(cHTTPServer & a_HTTPServer, const cX509CertPtr & a_Cert, const cCryptoKeyPtr & a_PrivateKey) :
+cSslHTTPServerConnection::cSslHTTPServerConnection(cHTTPServer & a_HTTPServer, const cX509CertPtr & a_Cert, const cCryptoKeyPtr & a_PrivateKey) :
super(a_HTTPServer),
m_Ssl(64000),
m_Cert(a_Cert),
@@ -25,7 +25,7 @@ cSslHTTPConnection::cSslHTTPConnection(cHTTPServer & a_HTTPServer, const cX509Ce
-cSslHTTPConnection::~cSslHTTPConnection()
+cSslHTTPServerConnection::~cSslHTTPServerConnection()
{
m_Ssl.NotifyClose();
}
@@ -34,7 +34,7 @@ cSslHTTPConnection::~cSslHTTPConnection()
-void cSslHTTPConnection::OnReceivedData(const char * a_Data, size_t a_Size)
+void cSslHTTPServerConnection::OnReceivedData(const char * a_Data, size_t a_Size)
{
// Process the received data:
const char * Data = a_Data;
@@ -77,7 +77,7 @@ void cSslHTTPConnection::OnReceivedData(const char * a_Data, size_t a_Size)
-void cSslHTTPConnection::SendData(const void * a_Data, size_t a_Size)
+void cSslHTTPServerConnection::SendData(const void * a_Data, size_t a_Size)
{
const char * OutgoingData = reinterpret_cast<const char *>(a_Data);
size_t pos = 0;
diff --git a/src/HTTPServer/SslHTTPConnection.h b/src/HTTPServer/SslHTTPServerConnection.h
index b35bd8ba0..6032a2bd0 100644
--- a/src/HTTPServer/SslHTTPConnection.h
+++ b/src/HTTPServer/SslHTTPServerConnection.h
@@ -1,7 +1,7 @@
-// SslHTTPConnection.h
+// SslHTTPServerConnection.h
-// Declared the cSslHTTPConnection class representing a HTTP connection made over a SSL link
+// Declared the cSslHTTPServerConnection class representing a HTTP connection made over a SSL link
@@ -9,24 +9,24 @@
#pragma once
-#include "HTTPConnection.h"
+#include "HTTPServerConnection.h"
#include "PolarSSL++/BufferedSslContext.h"
-class cSslHTTPConnection :
- public cHTTPConnection
+class cSslHTTPServerConnection :
+ public cHTTPServerConnection
{
- typedef cHTTPConnection super;
+ typedef cHTTPServerConnection super;
public:
/** Creates a new connection on the specified server.
Sends the specified cert as the server certificate, uses the private key for decryption. */
- cSslHTTPConnection(cHTTPServer & a_HTTPServer, const cX509CertPtr & a_Cert, const cCryptoKeyPtr & a_PrivateKey);
+ cSslHTTPServerConnection(cHTTPServer & a_HTTPServer, const cX509CertPtr & a_Cert, const cCryptoKeyPtr & a_PrivateKey);
- ~cSslHTTPConnection();
+ ~cSslHTTPServerConnection();
protected:
cBufferedSslContext m_Ssl;