mirror of https://github.com/adamdruppe/arsd.git
mutation done now to mask so a copy is necessary. can maybe optimize later but this avoids mem prot errors when passed string literals and other surprised when pssed temporaries
This commit is contained in:
parent
28a3d87591
commit
0c2bcea779
8
cgi.d
8
cgi.d
|
@ -5610,7 +5610,7 @@ version(cgi_with_websocket) {
|
||||||
WebSocketFrame wss;
|
WebSocketFrame wss;
|
||||||
wss.fin = true;
|
wss.fin = true;
|
||||||
wss.opcode = WebSocketOpcode.close;
|
wss.opcode = WebSocketOpcode.close;
|
||||||
wss.data = cast(ubyte[]) reason;
|
wss.data = cast(ubyte[]) reason.dup;
|
||||||
wss.send(&llsend);
|
wss.send(&llsend);
|
||||||
|
|
||||||
readyState_ = CLOSING;
|
readyState_ = CLOSING;
|
||||||
|
@ -5645,7 +5645,7 @@ version(cgi_with_websocket) {
|
||||||
WebSocketFrame wss;
|
WebSocketFrame wss;
|
||||||
wss.fin = true;
|
wss.fin = true;
|
||||||
wss.opcode = WebSocketOpcode.text;
|
wss.opcode = WebSocketOpcode.text;
|
||||||
wss.data = cast(ubyte[]) textData;
|
wss.data = cast(ubyte[]) textData.dup;
|
||||||
wss.send(&llsend);
|
wss.send(&llsend);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5657,7 +5657,7 @@ version(cgi_with_websocket) {
|
||||||
WebSocketFrame wss;
|
WebSocketFrame wss;
|
||||||
wss.fin = true;
|
wss.fin = true;
|
||||||
wss.opcode = WebSocketOpcode.binary;
|
wss.opcode = WebSocketOpcode.binary;
|
||||||
wss.data = cast(ubyte[]) binaryData;
|
wss.data = cast(ubyte[]) binaryData.dup;
|
||||||
wss.send(&llsend);
|
wss.send(&llsend);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5895,7 +5895,7 @@ version(cgi_with_websocket) {
|
||||||
WebSocketFrame msg;
|
WebSocketFrame msg;
|
||||||
msg.fin = true;
|
msg.fin = true;
|
||||||
msg.opcode = opcode;
|
msg.opcode = opcode;
|
||||||
msg.data = cast(ubyte[]) data;
|
msg.data = cast(ubyte[]) data.dup;
|
||||||
|
|
||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
|
|
10
http2.d
10
http2.d
|
@ -3696,7 +3696,7 @@ class WebSocket {
|
||||||
WebSocketFrame wss;
|
WebSocketFrame wss;
|
||||||
wss.fin = true;
|
wss.fin = true;
|
||||||
wss.opcode = WebSocketOpcode.close;
|
wss.opcode = WebSocketOpcode.close;
|
||||||
wss.data = cast(ubyte[]) reason;
|
wss.data = cast(ubyte[]) reason.dup;
|
||||||
wss.send(&llsend);
|
wss.send(&llsend);
|
||||||
|
|
||||||
readyState_ = CLOSING;
|
readyState_ = CLOSING;
|
||||||
|
@ -3732,7 +3732,7 @@ class WebSocket {
|
||||||
wss.fin = true;
|
wss.fin = true;
|
||||||
wss.masked = this.isClient;
|
wss.masked = this.isClient;
|
||||||
wss.opcode = WebSocketOpcode.text;
|
wss.opcode = WebSocketOpcode.text;
|
||||||
wss.data = cast(ubyte[]) textData;
|
wss.data = cast(ubyte[]) textData.dup;
|
||||||
wss.send(&llsend);
|
wss.send(&llsend);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3745,7 +3745,7 @@ class WebSocket {
|
||||||
wss.masked = this.isClient;
|
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.dup;
|
||||||
wss.send(&llsend);
|
wss.send(&llsend);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4065,11 +4065,11 @@ public {
|
||||||
ubyte[4] maskingKey; // don't set this when sending
|
ubyte[4] maskingKey; // don't set this when sending
|
||||||
ubyte[] data;
|
ubyte[] data;
|
||||||
|
|
||||||
static WebSocketFrame simpleMessage(WebSocketOpcode opcode, void[] data) {
|
static WebSocketFrame simpleMessage(WebSocketOpcode opcode, in void[] data) {
|
||||||
WebSocketFrame msg;
|
WebSocketFrame msg;
|
||||||
msg.fin = true;
|
msg.fin = true;
|
||||||
msg.opcode = opcode;
|
msg.opcode = opcode;
|
||||||
msg.data = cast(ubyte[]) data;
|
msg.data = cast(ubyte[]) data.dup; // it is mutated below when masked, so need to be cautious and copy it, sigh
|
||||||
|
|
||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue