Issue 22: Don't send Sec-WebSocket-Protocol unless specified

This commit is contained in:
JCash 2020-11-09 19:03:27 +01:00
parent 0bf63cbdf8
commit b93a91c9b8
2 changed files with 5 additions and 7 deletions

View File

@ -23,7 +23,7 @@
- name: protocol - name: protocol
type: string type: string
desc: the protocol to use (e.g. 'chat'). (Default is 'binary') desc: the protocol to use (e.g. 'chat'). If not set, no `Sec-WebSocket-Protocol` header is sent.
- name: headers - name: headers
type: string type: string

View File

@ -712,12 +712,10 @@ static dmExtension::Result OnUpdate(dmExtension::Params* params)
#if defined(__EMSCRIPTEN__) #if defined(__EMSCRIPTEN__)
conn->m_SSLSocket = dmSSLSocket::INVALID_SOCKET_HANDLE; conn->m_SSLSocket = dmSSLSocket::INVALID_SOCKET_HANDLE;
if (conn->m_Protocol) { EM_ASM({
EM_ASM({ // https://emscripten.org/docs/porting/networking.html#emulated-posix-tcp-sockets-over-websockets
// https://emscripten.org/docs/porting/networking.html#emulated-posix-tcp-sockets-over-websockets Module["websocket"]["subprotocol"] = $0 ? UTF8ToString($0) : null;
Module["websocket"]["subprotocol"] = UTF8ToString($0); }, conn->m_Protocol);
}, conn->m_Protocol);
}
char uri_buffer[dmURI::MAX_URI_LEN]; char uri_buffer[dmURI::MAX_URI_LEN];
const char* uri; const char* uri;