From b2e7a536294323bb862517f9b3aa6257d526ac62 Mon Sep 17 00:00:00 2001 From: orignal Date: Fri, 12 Sep 2014 15:57:34 -0400 Subject: [PATCH] fixed malformed messages --- HTTPProxy.cpp | 10 +++------- HTTPServer.cpp | 8 ++++---- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/HTTPProxy.cpp b/HTTPProxy.cpp index dbb52b22..22365357 100644 --- a/HTTPProxy.cpp +++ b/HTTPProxy.cpp @@ -63,15 +63,11 @@ namespace proxy request r; ExtractRequest(r); parseHeaders(m_Buffer, r.headers); - size_t len = 0; const char * data = strstr (m_Buffer, "\r\n\r\n"); - if (data) - { - data += 4; - len = strlen (m_Buffer) - (data - m_Buffer); - } + if (data) data += 4; + LogPrint("Requesting ", r.host, " with path ", r.uri, " and method ", r.method); - HandleDestinationRequest(r.host, r.method, len > 0 ? std::string (data, len) : "" , r.uri); + HandleDestinationRequest(r.host, r.method, data ? std::string (data) : "" , r.uri); } } diff --git a/HTTPServer.cpp b/HTTPServer.cpp index c0fcd413..b9d24a1d 100644 --- a/HTTPServer.cpp +++ b/HTTPServer.cpp @@ -701,7 +701,7 @@ namespace util if (i2p::data::Base32ToByteStream(address.c_str(), address.length() - strlen(".b32.i2p"), (uint8_t *)destination, 32) != 32) { LogPrint ("Invalid Base32 address ", address); - SendReply ("" + itoopieImage + "
Invalid Base32 address", 400); + SendReply ("" + itoopieImage + "
Invalid Base32 address", 400); return; } fullAddress = address; @@ -714,7 +714,7 @@ namespace util if (!addr) { LogPrint ("Unknown address ", address); - SendReply ("" + itoopieImage + "
Unknown address " + address + "", 105); + SendReply ("" + itoopieImage + "
Unknown address " + address + "", 404); return; } destination = *addr; @@ -735,7 +735,7 @@ namespace util if (i2p::data::Base32ToByteStream(address.c_str(), address.length(), (uint8_t *)destination, 32) != 32) { LogPrint("Invalid Base32 address ", address); - SendReply("" + itoopieImage + "
Invalid Base32 address", 400); + SendReply("" + itoopieImage + "
Invalid Base32 address", 400); return; } fullAddress = address + ".b32.i2p"; @@ -766,7 +766,7 @@ namespace util // POST/PUT, apply body request += "Content-Length: " ; request += data.size (); - request += "\r\n" + data; + request += "\r\n\r\n" + data; } LogPrint("HTTP Client Request: ", request); m_Stream->Send ((uint8_t *)request.c_str (), request.size (), 10);