fix(http2): mask outgoing ws messages as client

This commit is contained in:
Tobias Pankrath 2021-09-18 15:36:01 +02:00
parent 7515fcafae
commit e0d767625a
1 changed files with 6 additions and 0 deletions

View File

@ -3293,6 +3293,9 @@ class WebSocket {
private ushort port; private ushort port;
private bool ssl; private bool ssl;
// used to decide if we mask outgoing msgs
private bool isClient;
private MonoTime timeoutFromInactivity; private MonoTime timeoutFromInactivity;
private MonoTime nextPing; private MonoTime nextPing;
@ -3329,6 +3332,7 @@ class WebSocket {
+/ +/
/// Group: foundational /// Group: foundational
void connect() { void connect() {
this.isClient = true;
if(uri.unixSocketPath) if(uri.unixSocketPath)
socket.connect(new UnixAddress(uri.unixSocketPath)); socket.connect(new UnixAddress(uri.unixSocketPath));
else else
@ -3712,6 +3716,7 @@ class WebSocket {
void send(in char[] textData) { void send(in char[] textData) {
WebSocketFrame wss; WebSocketFrame wss;
wss.fin = true; wss.fin = true;
wss.masked = this.isClient;
wss.opcode = WebSocketOpcode.text; wss.opcode = WebSocketOpcode.text;
wss.data = cast(ubyte[]) textData; wss.data = cast(ubyte[]) textData;
wss.send(&llsend); wss.send(&llsend);
@ -3723,6 +3728,7 @@ class WebSocket {
/// Group: foundational /// Group: foundational
void send(in ubyte[] binaryData) { void send(in ubyte[] binaryData) {
WebSocketFrame wss; WebSocketFrame wss;
wss.masked = this.isClient;
wss.fin = true; wss.fin = true;
wss.opcode = WebSocketOpcode.binary; wss.opcode = WebSocketOpcode.binary;
wss.data = cast(ubyte[]) binaryData; wss.data = cast(ubyte[]) binaryData;