Browse Source

fixed malformed messages

pull/97/head
orignal 10 years ago
parent
commit
b2e7a53629
  1. 10
      HTTPProxy.cpp
  2. 8
      HTTPServer.cpp

10
HTTPProxy.cpp

@ -63,15 +63,11 @@ namespace proxy
request r; request r;
ExtractRequest(r); ExtractRequest(r);
parseHeaders(m_Buffer, r.headers); parseHeaders(m_Buffer, r.headers);
size_t len = 0;
const char * data = strstr (m_Buffer, "\r\n\r\n"); const char * data = strstr (m_Buffer, "\r\n\r\n");
if (data) if (data) data += 4;
{
data += 4;
len = strlen (m_Buffer) - (data - m_Buffer);
}
LogPrint("Requesting ", r.host, " with path ", r.uri, " and method ", r.method); 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);
} }
} }

8
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) if (i2p::data::Base32ToByteStream(address.c_str(), address.length() - strlen(".b32.i2p"), (uint8_t *)destination, 32) != 32)
{ {
LogPrint ("Invalid Base32 address ", address); LogPrint ("Invalid Base32 address ", address);
SendReply ("<html>" + itoopieImage + "<br>Invalid Base32 address", 400); SendReply ("<html>" + itoopieImage + "<br>Invalid Base32 address</hmtl>", 400);
return; return;
} }
fullAddress = address; fullAddress = address;
@ -714,7 +714,7 @@ namespace util
if (!addr) if (!addr)
{ {
LogPrint ("Unknown address ", address); LogPrint ("Unknown address ", address);
SendReply ("<html>" + itoopieImage + "<br>Unknown address " + address + "</html>", 105); SendReply ("<html>" + itoopieImage + "<br>Unknown address " + address + "</html>", 404);
return; return;
} }
destination = *addr; destination = *addr;
@ -735,7 +735,7 @@ namespace util
if (i2p::data::Base32ToByteStream(address.c_str(), address.length(), (uint8_t *)destination, 32) != 32) if (i2p::data::Base32ToByteStream(address.c_str(), address.length(), (uint8_t *)destination, 32) != 32)
{ {
LogPrint("Invalid Base32 address ", address); LogPrint("Invalid Base32 address ", address);
SendReply("<html>" + itoopieImage + "<br>Invalid Base32 address", 400); SendReply("<html>" + itoopieImage + "<br>Invalid Base32 address</hmtl>", 400);
return; return;
} }
fullAddress = address + ".b32.i2p"; fullAddress = address + ".b32.i2p";
@ -766,7 +766,7 @@ namespace util
// POST/PUT, apply body // POST/PUT, apply body
request += "Content-Length: " ; request += "Content-Length: " ;
request += data.size (); request += data.size ();
request += "\r\n" + data; request += "\r\n\r\n" + data;
} }
LogPrint("HTTP Client Request: ", request); LogPrint("HTTP Client Request: ", request);
m_Stream->Send ((uint8_t *)request.c_str (), request.size (), 10); m_Stream->Send ((uint8_t *)request.c_str (), request.size (), 10);

Loading…
Cancel
Save