merge WebSocket fixes from devel

This commit is contained in:
Günter Obiltschnig
2021-04-11 16:46:48 +02:00
parent 0a2a175f8a
commit b30bebffb0
2 changed files with 16 additions and 4 deletions

View File

@@ -150,6 +150,9 @@ public:
/// ///
/// The result of the handshake can be obtained from the response /// The result of the handshake can be obtained from the response
/// object. /// object.
///
/// The HTTPClientSession session object must no longer be used after setting
/// up the WebSocket.
WebSocket(HTTPClientSession& cs, HTTPRequest& request, HTTPResponse& response, HTTPCredentials& credentials); WebSocket(HTTPClientSession& cs, HTTPRequest& request, HTTPResponse& response, HTTPCredentials& credentials);
/// Creates a client-side WebSocket, using the given /// Creates a client-side WebSocket, using the given
@@ -165,6 +168,9 @@ public:
/// ///
/// The result of the handshake can be obtained from the response /// The result of the handshake can be obtained from the response
/// object. /// object.
///
/// The HTTPClientSession session object must no longer be used after setting
/// up the WebSocket.
WebSocket(const Socket& socket); WebSocket(const Socket& socket);
/// Creates a WebSocket from another Socket, which must be a WebSocket, /// Creates a WebSocket from another Socket, which must be a WebSocket,
@@ -218,9 +224,11 @@ public:
/// A WebSocketException will also be thrown if a malformed /// A WebSocketException will also be thrown if a malformed
/// or incomplete frame is received. /// or incomplete frame is received.
/// ///
/// Returns the number of bytes received. /// Returns the number of payload bytes received.
/// A return value of 0 means that the peer has /// A return value of 0, with flags also 0, means that the peer has
/// shut down or closed the connection. /// shut down or closed the connection.
/// A return value of 0, with non-zero flags, indicates an
/// reception of an empty frame (e.g., in case of a PING).
/// ///
/// Throws a TimeoutException if a receive timeout has /// Throws a TimeoutException if a receive timeout has
/// been set and nothing is received within that interval. /// been set and nothing is received within that interval.
@@ -248,9 +256,11 @@ public:
/// DoS attack (memory exhaustion) by sending a WebSocket frame /// DoS attack (memory exhaustion) by sending a WebSocket frame
/// header with a huge payload size. /// header with a huge payload size.
/// ///
/// Returns the number of bytes received. /// Returns the number of payload bytes received.
/// A return value of 0 means that the peer has /// A return value of 0, with flags also 0, means that the peer has
/// shut down or closed the connection. /// shut down or closed the connection.
/// A return value of 0, with non-zero flags, indicates an
/// reception of an empty frame (e.g., in case of a PING).
/// ///
/// Throws a TimeoutException if a receive timeout has /// Throws a TimeoutException if a receive timeout has
/// been set and nothing is received within that interval. /// been set and nothing is received within that interval.

View File

@@ -203,6 +203,7 @@ int WebSocketImpl::receiveBytes(void* buffer, int length, int)
{ {
char mask[4]; char mask[4];
bool useMask; bool useMask;
_frameFlags = 0;
int payloadLength = receiveHeader(mask, useMask); int payloadLength = receiveHeader(mask, useMask);
if (payloadLength <= 0) if (payloadLength <= 0)
return payloadLength; return payloadLength;
@@ -216,6 +217,7 @@ int WebSocketImpl::receiveBytes(Poco::Buffer<char>& buffer, int, const Poco::Tim
{ {
char mask[4]; char mask[4];
bool useMask; bool useMask;
_frameFlags = 0;
int payloadLength = receiveHeader(mask, useMask); int payloadLength = receiveHeader(mask, useMask);
if (payloadLength <= 0) if (payloadLength <= 0)
return payloadLength; return payloadLength;