From 1eb9cf735de844d844f7d6191ac8b7bb9913214f Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Mon, 20 May 2019 12:58:58 -0700 Subject: Threshold between medium and large messages was wrong. --- src/unstable/protocolwebsocket.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/unstable/protocolwebsocket.cpp b/src/unstable/protocolwebsocket.cpp index 0beb5d4..9e8b1de 100644 --- a/src/unstable/protocolwebsocket.cpp +++ b/src/unstable/protocolwebsocket.cpp @@ -67,6 +67,7 @@ void Bu::ProtocolWebSocket::onNewData( Bu::Client * /*pClient*/ ) void Bu::ProtocolWebSocket::writeMessage( const Bu::String &sData, Bu::ProtocolWebSocket::Operation eOp ) { + //Bu::println("websocket: Writing message, %1 bytes").arg( sData.getSize() ); uint8_t cHeader[32]; //uint8_t *cMask; memset( cHeader, 0, 32 ); @@ -78,10 +79,12 @@ void Bu::ProtocolWebSocket::writeMessage( const Bu::String &sData, uint64_t iLen = sData.getSize(); if( iLen < 126 ) { + //Bu::println("websocket: --> Tiny header"); cHeader[1] = ((uint8_t)iLen); } - else if( iLen < 2147483648 ) + else if( iLen < 65536 ) { + //Bu::println("websocket: --> Mid header"); cHeader[1] = ((uint8_t)126); uint16_t uLen = iLen; uLen = htobe16( uLen ); @@ -90,6 +93,7 @@ void Bu::ProtocolWebSocket::writeMessage( const Bu::String &sData, } else { +// Bu::println("websocket: --> Big header?"); cHeader[1] = ((uint8_t)127); uint64_t iTmp = htobe64( iLen ); memcpy( cHeader+idx, &iTmp, 8 ); @@ -145,6 +149,8 @@ bool Bu::ProtocolWebSocket::stateProtoId() bool Bu::ProtocolWebSocket::stateHandshake() { + //Bu::println("websocket: Begining handshake."); + Bu::String sLine; if( !readHttpHdrLine( sLine ) ) return false; @@ -234,6 +240,8 @@ bool Bu::ProtocolWebSocket::processHeaders() "\r\n" ); + //Bu::println("websocket: Switching protocols."); + return true; } @@ -253,6 +261,8 @@ bool Bu::ProtocolWebSocket::headerMatch( const Bu::String &sKey, const Bu::Strin bool Bu::ProtocolWebSocket::parseMessage() { + //Bu::println("websocket: Recieved message, input available: %1").arg( pClient->getInputSize() ); + if( pClient->getInputSize() < 2 ) return false; -- cgit v1.2.3