summaryrefslogtreecommitdiffstats
path: root/source/HTTPServer/HTTPConnection.cpp
diff options
context:
space:
mode:
authormadmaxoft <github@xoft.cz>2013-09-27 21:28:41 +0200
committermadmaxoft <github@xoft.cz>2013-09-27 21:28:41 +0200
commit5cf8fc12ae000cd2d2b54a2bf158f82bdb8a0e67 (patch)
tree9c1f8b1f21555751b6a5886cf32a492a1e504c85 /source/HTTPServer/HTTPConnection.cpp
parentFixed leaking HTTPRequest objects (diff)
downloadcuberite-5cf8fc12ae000cd2d2b54a2bf158f82bdb8a0e67.tar
cuberite-5cf8fc12ae000cd2d2b54a2bf158f82bdb8a0e67.tar.gz
cuberite-5cf8fc12ae000cd2d2b54a2bf158f82bdb8a0e67.tar.bz2
cuberite-5cf8fc12ae000cd2d2b54a2bf158f82bdb8a0e67.tar.lz
cuberite-5cf8fc12ae000cd2d2b54a2bf158f82bdb8a0e67.tar.xz
cuberite-5cf8fc12ae000cd2d2b54a2bf158f82bdb8a0e67.tar.zst
cuberite-5cf8fc12ae000cd2d2b54a2bf158f82bdb8a0e67.zip
Diffstat (limited to 'source/HTTPServer/HTTPConnection.cpp')
-rw-r--r--source/HTTPServer/HTTPConnection.cpp35
1 files changed, 34 insertions, 1 deletions
diff --git a/source/HTTPServer/HTTPConnection.cpp b/source/HTTPServer/HTTPConnection.cpp
index 2265d970f..c36b07d3d 100644
--- a/source/HTTPServer/HTTPConnection.cpp
+++ b/source/HTTPServer/HTTPConnection.cpp
@@ -69,6 +69,39 @@ void cHTTPConnection::FinishResponse(void)
+void cHTTPConnection::AwaitNextRequest(void)
+{
+ switch (m_State)
+ {
+ case wcsRecvIdle:
+ {
+ // The client is waiting for a response, send an "Internal server error":
+ m_OutgoingData.append("HTTP/1.1 500 Internal Server Error\r\n\r\n");
+ m_HTTPServer.NotifyConnectionWrite(*this);
+ m_State = wcsRecvHeaders;
+ break;
+ }
+
+ case wcsSendingResp:
+ {
+ // The response headers have been sent, we need to terminate the response body:
+ m_OutgoingData.append("0\r\n\r\n");
+ m_State = wcsRecvHeaders;
+ break;
+ }
+
+ default:
+ {
+ ASSERT(!"Unhandled state recovery");
+ break;
+ }
+ }
+}
+
+
+
+
+
void cHTTPConnection::DataReceived(const char * a_Data, int a_Size)
{
switch (m_State)
@@ -128,10 +161,10 @@ void cHTTPConnection::DataReceived(const char * a_Data, int a_Size)
}
if (m_CurrentRequestBodyRemaining == 0)
{
+ m_State = wcsRecvIdle;
m_HTTPServer.RequestFinished(*this, *m_CurrentRequest);
delete m_CurrentRequest;
m_CurrentRequest = NULL;
- m_State = wcsRecvIdle;
}
break;
}