mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-25 02:06:04 +02:00
porting 1.4.4 rev. 1929, 1939 (SF# 3552680 et. al)
This commit is contained in:
@@ -118,9 +118,28 @@ int WebSocketImpl::sendBytes(const void* buffer, int length, int flags)
|
||||
int WebSocketImpl::receiveBytes(void* buffer, int length, int)
|
||||
{
|
||||
char header[MAX_HEADER_LENGTH];
|
||||
int n = _pStreamSocketImpl->receiveBytes(header, MAX_HEADER_LENGTH);
|
||||
int n = _pStreamSocketImpl->receiveBytes(header, 2);
|
||||
if (n == 1)
|
||||
{
|
||||
n += _pStreamSocketImpl->receiveBytes(header + 1, 1);
|
||||
}
|
||||
if (n == 2)
|
||||
{
|
||||
Poco::UInt8 lengthByte = static_cast<Poco::UInt8>(header[1]) & 0x7f;
|
||||
if (lengthByte + 2 < MAX_HEADER_LENGTH)
|
||||
{
|
||||
n = _pStreamSocketImpl->receiveBytes(header + 2, lengthByte);
|
||||
}
|
||||
else
|
||||
{
|
||||
n = _pStreamSocketImpl->receiveBytes(header + 2, MAX_HEADER_LENGTH - 2);
|
||||
}
|
||||
}
|
||||
else throw WebSocketException("Incomplete frame received", WebSocket::WS_ERR_INCOMPLETE_FRAME);
|
||||
|
||||
if (n > 0)
|
||||
{
|
||||
n += 2;
|
||||
Poco::MemoryInputStream istr(header, n);
|
||||
Poco::BinaryReader reader(istr, Poco::BinaryReader::NETWORK_BYTE_ORDER);
|
||||
Poco::UInt8 flags;
|
||||
|
||||
Reference in New Issue
Block a user