1
0
mirror of https://github.com/PurpleI2P/i2pd.git synced 2025-01-22 08:14:15 +00:00

POST longer messages

This commit is contained in:
orignal 2014-09-16 10:28:45 -04:00
parent 52fddadc98
commit 3a8bf1e38f
2 changed files with 12 additions and 5 deletions

View File

@ -512,7 +512,7 @@ namespace util
void HTTPConnection::Receive () void HTTPConnection::Receive ()
{ {
m_Socket->async_read_some (boost::asio::buffer (m_Buffer, 8191), m_Socket->async_read_some (boost::asio::buffer (m_Buffer, HTTP_CONNECTION_BUFFER_SIZE),
boost::bind(&HTTPConnection::HandleReceive, this, boost::bind(&HTTPConnection::HandleReceive, this,
boost::asio::placeholders::error, boost::asio::placeholders::bytes_transferred)); boost::asio::placeholders::error, boost::asio::placeholders::bytes_transferred));
} }
@ -521,9 +521,15 @@ namespace util
{ {
if (!ecode) if (!ecode)
{ {
m_Buffer[bytes_transferred] = 0; if (!m_Stream) // new request
m_BufferLen = bytes_transferred; {
RunRequest(); m_Buffer[bytes_transferred] = 0;
m_BufferLen = bytes_transferred;
RunRequest();
}
else // follow-on
m_Stream->Send ((uint8_t *)m_Buffer, bytes_transferred, 10);
Receive ();
} }
else if (ecode != boost::asio::error::operation_aborted) else if (ecode != boost::asio::error::operation_aborted)
Terminate (); Terminate ();

View File

@ -11,6 +11,7 @@ namespace i2p
{ {
namespace util namespace util
{ {
const size_t HTTP_CONNECTION_BUFFER_SIZE = 8192;
class HTTPConnection class HTTPConnection
{ {
protected: protected:
@ -68,7 +69,7 @@ namespace util
boost::asio::ip::tcp::socket * m_Socket; boost::asio::ip::tcp::socket * m_Socket;
i2p::stream::Stream * m_Stream; i2p::stream::Stream * m_Stream;
char m_Buffer[8192], m_StreamBuffer[8192]; char m_Buffer[HTTP_CONNECTION_BUFFER_SIZE + 1], m_StreamBuffer[HTTP_CONNECTION_BUFFER_SIZE + 1];
size_t m_BufferLen; size_t m_BufferLen;
request m_Request; request m_Request;
reply m_Reply; reply m_Reply;