Merge pull request #304 from Panke/http2-mask-msgs

fix(http2): mask outgoing ws messages as client
This commit is contained in:
Adam D. Ruppe 2021-09-18 09:50:30 -04:00 committed by GitHub
commit d2d7cfc539
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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;