From 1795cca5522476006d33d0c276e27a50659c867a Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Tue, 1 Apr 2014 16:36:00 +0200 Subject: Rewritten HTTPServer to use size_t for data lengths. --- src/HTTPServer/HTTPConnection.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/HTTPServer/HTTPConnection.cpp') diff --git a/src/HTTPServer/HTTPConnection.cpp b/src/HTTPServer/HTTPConnection.cpp index 78b7ce4d9..b8635d893 100644 --- a/src/HTTPServer/HTTPConnection.cpp +++ b/src/HTTPServer/HTTPConnection.cpp @@ -67,7 +67,7 @@ void cHTTPConnection::Send(const cHTTPResponse & a_Response) -void cHTTPConnection::Send(const void * a_Data, int a_Size) +void cHTTPConnection::Send(const void * a_Data, size_t a_Size) { ASSERT(m_State == wcsSendingResp); AppendPrintf(m_OutgoingData, "%x\r\n", a_Size); @@ -155,8 +155,8 @@ void cHTTPConnection::DataReceived(const char * a_Data, int a_Size) m_CurrentRequest = new cHTTPRequest; } - int BytesConsumed = m_CurrentRequest->ParseHeaders(a_Data, a_Size); - if (BytesConsumed < 0) + size_t BytesConsumed = m_CurrentRequest->ParseHeaders(a_Data, a_Size); + if (BytesConsumed == AString::npos) { delete m_CurrentRequest; m_CurrentRequest = NULL; @@ -174,16 +174,16 @@ void cHTTPConnection::DataReceived(const char * a_Data, int a_Size) m_State = wcsRecvBody; m_HTTPServer.NewRequest(*this, *m_CurrentRequest); m_CurrentRequestBodyRemaining = m_CurrentRequest->GetContentLength(); - if (m_CurrentRequestBodyRemaining < 0) + if (m_CurrentRequestBodyRemaining == AString::npos) { // The body length was not specified in the request, assume zero m_CurrentRequestBodyRemaining = 0; } // Process the rest of the incoming data into the request body: - if (a_Size > BytesConsumed) + if (a_Size > (int)BytesConsumed) { - DataReceived(a_Data + BytesConsumed, a_Size - BytesConsumed); + DataReceived(a_Data + BytesConsumed, a_Size - (int)BytesConsumed); } else { @@ -197,7 +197,7 @@ void cHTTPConnection::DataReceived(const char * a_Data, int a_Size) ASSERT(m_CurrentRequest != NULL); if (m_CurrentRequestBodyRemaining > 0) { - int BytesToConsume = std::min(m_CurrentRequestBodyRemaining, a_Size); + size_t BytesToConsume = std::min(m_CurrentRequestBodyRemaining, (size_t)a_Size); m_HTTPServer.RequestBody(*this, *m_CurrentRequest, a_Data, BytesToConsume); m_CurrentRequestBodyRemaining -= BytesToConsume; } -- cgit v1.2.3 From 7ece0cc8369a7600ea8667188e83a2cb9ef6570b Mon Sep 17 00:00:00 2001 From: Tycho Date: Wed, 2 Apr 2014 05:10:08 -0700 Subject: Fixed format string in HTTPConnection --- src/HTTPServer/HTTPConnection.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/HTTPServer/HTTPConnection.cpp') diff --git a/src/HTTPServer/HTTPConnection.cpp b/src/HTTPServer/HTTPConnection.cpp index b8635d893..6d238f028 100644 --- a/src/HTTPServer/HTTPConnection.cpp +++ b/src/HTTPServer/HTTPConnection.cpp @@ -70,7 +70,7 @@ void cHTTPConnection::Send(const cHTTPResponse & a_Response) void cHTTPConnection::Send(const void * a_Data, size_t a_Size) { ASSERT(m_State == wcsSendingResp); - AppendPrintf(m_OutgoingData, "%x\r\n", a_Size); + AppendPrintf(m_OutgoingData, SIZE_T_FMT "\r\n", a_Size); m_OutgoingData.append((const char *)a_Data, a_Size); m_OutgoingData.append("\r\n"); m_HTTPServer.NotifyConnectionWrite(*this); -- cgit v1.2.3 From 1f5a4a39f2cd9f63a7e5695689042d3c43b2e83b Mon Sep 17 00:00:00 2001 From: Tycho Date: Wed, 2 Apr 2014 06:36:25 -0700 Subject: Fixed All signedness warnings in HTTPServer.cpp --- src/HTTPServer/HTTPConnection.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/HTTPServer/HTTPConnection.cpp') diff --git a/src/HTTPServer/HTTPConnection.cpp b/src/HTTPServer/HTTPConnection.cpp index 6d238f028..44a3d3f88 100644 --- a/src/HTTPServer/HTTPConnection.cpp +++ b/src/HTTPServer/HTTPConnection.cpp @@ -144,7 +144,7 @@ void cHTTPConnection::Terminate(void) -void cHTTPConnection::DataReceived(const char * a_Data, int a_Size) +void cHTTPConnection::DataReceived(const char * a_Data, size_t a_Size) { switch (m_State) { @@ -181,9 +181,9 @@ void cHTTPConnection::DataReceived(const char * a_Data, int a_Size) } // Process the rest of the incoming data into the request body: - if (a_Size > (int)BytesConsumed) + if (a_Size > BytesConsumed) { - DataReceived(a_Data + BytesConsumed, a_Size - (int)BytesConsumed); + DataReceived(a_Data + BytesConsumed, a_Size - BytesConsumed); } else { -- cgit v1.2.3 From f9b2c2956efff75c71af6d3f18f615bc0cd345d4 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Mon, 7 Apr 2014 08:11:56 +0200 Subject: Fixed HTTP chunked encoding. Fixes #858. --- src/HTTPServer/HTTPConnection.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/HTTPServer/HTTPConnection.cpp') diff --git a/src/HTTPServer/HTTPConnection.cpp b/src/HTTPServer/HTTPConnection.cpp index 44a3d3f88..da4df0e34 100644 --- a/src/HTTPServer/HTTPConnection.cpp +++ b/src/HTTPServer/HTTPConnection.cpp @@ -70,7 +70,7 @@ void cHTTPConnection::Send(const cHTTPResponse & a_Response) void cHTTPConnection::Send(const void * a_Data, size_t a_Size) { ASSERT(m_State == wcsSendingResp); - AppendPrintf(m_OutgoingData, SIZE_T_FMT "\r\n", a_Size); + AppendPrintf(m_OutgoingData, SIZE_T_FMT_HEX "\r\n", a_Size); m_OutgoingData.append((const char *)a_Data, a_Size); m_OutgoingData.append("\r\n"); m_HTTPServer.NotifyConnectionWrite(*this); -- cgit v1.2.3