aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMike Buland <mbuland@penny-arcade.com>2019-05-20 12:58:58 -0700
committerMike Buland <mbuland@penny-arcade.com>2019-05-20 12:58:58 -0700
commit1eb9cf735de844d844f7d6191ac8b7bb9913214f (patch)
tree7615b7c3609b1cbac2d2ab97f91039360dfebadf /src
parent3e316641b129038831110232b0065a02c0cc0f0c (diff)
downloadlibbu++-1eb9cf735de844d844f7d6191ac8b7bb9913214f.tar.gz
libbu++-1eb9cf735de844d844f7d6191ac8b7bb9913214f.tar.bz2
libbu++-1eb9cf735de844d844f7d6191ac8b7bb9913214f.tar.xz
libbu++-1eb9cf735de844d844f7d6191ac8b7bb9913214f.zip
Threshold between medium and large messages was wrong.
Diffstat (limited to '')
-rw-r--r--src/unstable/protocolwebsocket.cpp12
1 files changed, 11 insertions, 1 deletions
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*/ )
67void Bu::ProtocolWebSocket::writeMessage( const Bu::String &sData, 67void Bu::ProtocolWebSocket::writeMessage( const Bu::String &sData,
68 Bu::ProtocolWebSocket::Operation eOp ) 68 Bu::ProtocolWebSocket::Operation eOp )
69{ 69{
70 //Bu::println("websocket: Writing message, %1 bytes").arg( sData.getSize() );
70 uint8_t cHeader[32]; 71 uint8_t cHeader[32];
71 //uint8_t *cMask; 72 //uint8_t *cMask;
72 memset( cHeader, 0, 32 ); 73 memset( cHeader, 0, 32 );
@@ -78,10 +79,12 @@ void Bu::ProtocolWebSocket::writeMessage( const Bu::String &sData,
78 uint64_t iLen = sData.getSize(); 79 uint64_t iLen = sData.getSize();
79 if( iLen < 126 ) 80 if( iLen < 126 )
80 { 81 {
82 //Bu::println("websocket: --> Tiny header");
81 cHeader[1] = ((uint8_t)iLen); 83 cHeader[1] = ((uint8_t)iLen);
82 } 84 }
83 else if( iLen < 2147483648 ) 85 else if( iLen < 65536 )
84 { 86 {
87 //Bu::println("websocket: --> Mid header");
85 cHeader[1] = ((uint8_t)126); 88 cHeader[1] = ((uint8_t)126);
86 uint16_t uLen = iLen; 89 uint16_t uLen = iLen;
87 uLen = htobe16( uLen ); 90 uLen = htobe16( uLen );
@@ -90,6 +93,7 @@ void Bu::ProtocolWebSocket::writeMessage( const Bu::String &sData,
90 } 93 }
91 else 94 else
92 { 95 {
96// Bu::println("websocket: --> Big header?");
93 cHeader[1] = ((uint8_t)127); 97 cHeader[1] = ((uint8_t)127);
94 uint64_t iTmp = htobe64( iLen ); 98 uint64_t iTmp = htobe64( iLen );
95 memcpy( cHeader+idx, &iTmp, 8 ); 99 memcpy( cHeader+idx, &iTmp, 8 );
@@ -145,6 +149,8 @@ bool Bu::ProtocolWebSocket::stateProtoId()
145 149
146bool Bu::ProtocolWebSocket::stateHandshake() 150bool Bu::ProtocolWebSocket::stateHandshake()
147{ 151{
152 //Bu::println("websocket: Begining handshake.");
153
148 Bu::String sLine; 154 Bu::String sLine;
149 if( !readHttpHdrLine( sLine ) ) 155 if( !readHttpHdrLine( sLine ) )
150 return false; 156 return false;
@@ -234,6 +240,8 @@ bool Bu::ProtocolWebSocket::processHeaders()
234 "\r\n" 240 "\r\n"
235 ); 241 );
236 242
243 //Bu::println("websocket: Switching protocols.");
244
237 return true; 245 return true;
238} 246}
239 247
@@ -253,6 +261,8 @@ bool Bu::ProtocolWebSocket::headerMatch( const Bu::String &sKey, const Bu::Strin
253 261
254bool Bu::ProtocolWebSocket::parseMessage() 262bool Bu::ProtocolWebSocket::parseMessage()
255{ 263{
264 //Bu::println("websocket: Recieved message, input available: %1").arg( pClient->getInputSize() );
265
256 if( pClient->getInputSize() < 2 ) 266 if( pClient->getInputSize() < 2 )
257 return false; 267 return false;
258 268