diff options
author | Alexander Larsson <alexl@redhat.com> | 2013-01-10 22:50:03 +0100 |
---|---|---|
committer | Alexander Larsson <alexl@redhat.com> | 2013-01-10 22:50:03 +0100 |
commit | da8ff82df578ae5073f07dd8ccb0e7c928dfd774 (patch) | |
tree | f7ffe61dc284b41d8f956d1f7455b33a04db7ad2 /gdk/broadway | |
parent | 2e76e5a543efa165dc2ae94cc1f5fcfe829e983c (diff) | |
download | gtk+-da8ff82df578ae5073f07dd8ccb0e7c928dfd774.tar.gz |
broadway: Make Sec-WebSocket-Origin optional
Sometimes we get no Origin in the request
Diffstat (limited to 'gdk/broadway')
-rw-r--r-- | gdk/broadway/broadway-server.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/gdk/broadway/broadway-server.c b/gdk/broadway/broadway-server.c index 3ee706f5ee..86f0053a1c 100644 --- a/gdk/broadway/broadway-server.c +++ b/gdk/broadway/broadway-server.c @@ -950,7 +950,7 @@ start_input (HttpRequest *request, gboolean binary) } } - if (origin == NULL || host == NULL) + if (host == NULL) { g_strfreev (lines); send_error (request, 400, "Bad websocket request"); @@ -964,10 +964,12 @@ start_input (HttpRequest *request, gboolean binary) "Upgrade: websocket\r\n" "Connection: Upgrade\r\n" "Sec-WebSocket-Accept: %s\r\n" - "Sec-WebSocket-Origin: %s\r\n" + "%s%s%s" "Sec-WebSocket-Location: ws://%s/socket\r\n" "Sec-WebSocket-Protocol: broadway\r\n" - "\r\n", accept, origin, host); + "\r\n", accept, + origin?"Sec-WebSocket-Origin: ":"", origin?origin:"", origin?"\r\n":"", + host); g_free (accept); #ifdef DEBUG_WEBSOCKETS @@ -1013,11 +1015,12 @@ start_input (HttpRequest *request, gboolean binary) res = g_strdup_printf ("HTTP/1.1 101 WebSocket Protocol Handshake\r\n" "Upgrade: WebSocket\r\n" "Connection: Upgrade\r\n" - "Sec-WebSocket-Origin: %s\r\n" + "%s%s%s" "Sec-WebSocket-Location: ws://%s/socket\r\n" "Sec-WebSocket-Protocol: broadway\r\n" "\r\n", - origin, host); + origin?"Sec-WebSocket-Origin: ":"", origin?origin:"", origin?"\r\n":"", + host); #ifdef DEBUG_WEBSOCKETS g_print ("legacy response:\n%s", res); |