mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2024-11-11 19:10:55 +00:00
read reamaining data from closed stream
This commit is contained in:
parent
bbe403fb40
commit
64df22def8
@ -462,17 +462,18 @@ namespace client
|
|||||||
{
|
{
|
||||||
if (bytes_transferred)
|
if (bytes_transferred)
|
||||||
response.write ((char *)buf, bytes_transferred);
|
response.write ((char *)buf, bytes_transferred);
|
||||||
else
|
if (ecode == boost::asio::error::timed_out || !stream->IsOpen ())
|
||||||
{
|
end = true;
|
||||||
if (ecode != boost::asio::error::timed_out || !stream->IsOpen ())
|
|
||||||
end = true;
|
|
||||||
}
|
|
||||||
newDataReceived.notify_all ();
|
newDataReceived.notify_all ();
|
||||||
},
|
},
|
||||||
30); // wait for 30 seconds
|
30); // wait for 30 seconds
|
||||||
std::unique_lock<std::mutex> l(newDataReceivedMutex);
|
std::unique_lock<std::mutex> l(newDataReceivedMutex);
|
||||||
newDataReceived.wait (l);
|
newDataReceived.wait (l);
|
||||||
}
|
}
|
||||||
|
// process remaining buffer
|
||||||
|
while (size_t len = stream->ReadSome (buf, 4096))
|
||||||
|
response.write ((char *)buf, len);
|
||||||
|
|
||||||
// parse response
|
// parse response
|
||||||
std::string version;
|
std::string version;
|
||||||
response >> version; // HTTP version
|
response >> version; // HTTP version
|
||||||
|
@ -100,6 +100,7 @@ namespace stream
|
|||||||
|
|
||||||
template<typename Buffer, typename ReceiveHandler>
|
template<typename Buffer, typename ReceiveHandler>
|
||||||
void AsyncReceive (const Buffer& buffer, ReceiveHandler handler, int timeout = 0);
|
void AsyncReceive (const Buffer& buffer, ReceiveHandler handler, int timeout = 0);
|
||||||
|
size_t ReadSome (uint8_t * buf, size_t len) { return ConcatenatePackets (buf, len); };
|
||||||
|
|
||||||
void Close ();
|
void Close ();
|
||||||
void Cancel () { m_ReceiveTimer.cancel (); };
|
void Cancel () { m_ReceiveTimer.cancel (); };
|
||||||
@ -225,7 +226,7 @@ namespace stream
|
|||||||
else
|
else
|
||||||
// socket closed
|
// socket closed
|
||||||
handler (m_IsReset ? boost::asio::error::make_error_code (boost::asio::error::connection_reset) :
|
handler (m_IsReset ? boost::asio::error::make_error_code (boost::asio::error::connection_reset) :
|
||||||
boost::asio::error::make_error_code (boost::asio::error::operation_aborted), 0);
|
boost::asio::error::make_error_code (boost::asio::error::operation_aborted), received);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
// timeout expired
|
// timeout expired
|
||||||
|
Loading…
Reference in New Issue
Block a user