(server) fix masking bug
This commit is contained in:
parent
f029321664
commit
804ec9246f
@ -124,9 +124,8 @@ namespace ix
|
||||
// Server
|
||||
WebSocketInitResult WebSocketTransport::connectToSocket(int fd, int timeoutSecs)
|
||||
{
|
||||
// Server should not mask the data it sends to the client (with _useMask = false)
|
||||
// However our unmasked code is broken right now for some reason, so disabling this.
|
||||
_useMask = true;
|
||||
// Server should not mask the data it sends to the client
|
||||
_useMask = false;
|
||||
|
||||
std::string errorMsg;
|
||||
_socket = createSocket(fd, errorMsg);
|
||||
@ -657,7 +656,8 @@ namespace ix
|
||||
std::vector<uint8_t> header;
|
||||
header.assign(2 +
|
||||
(message_size >= 126 ? 2 : 0) +
|
||||
(message_size >= 65536 ? 6 : 0) + 4, 0);
|
||||
(message_size >= 65536 ? 6 : 0) +
|
||||
(_useMask ? 4 : 0), 0);
|
||||
header[0] = type;
|
||||
|
||||
// The fin bit indicate that this is the last fragment. Fin is French for end.
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include <iostream>
|
||||
#include <stdlib.h>
|
||||
#include <stack>
|
||||
#include <iomanip>
|
||||
|
||||
namespace ix
|
||||
{
|
||||
@ -148,4 +149,21 @@ namespace ix
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
void hexDump(const std::string& prefix,
|
||||
const std::string& s)
|
||||
{
|
||||
std::ostringstream ss;
|
||||
bool upper_case = false;
|
||||
|
||||
for (std::string::size_type i = 0; i < s.length(); ++i)
|
||||
{
|
||||
ss << std::hex
|
||||
<< std::setfill('0')
|
||||
<< std::setw(2)
|
||||
<< (upper_case ? std::uppercase : std::nouppercase) << (int)s[i];
|
||||
}
|
||||
|
||||
std::cout << prefix << ": " << s << " => " << ss.str() << std::endl;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user