[gtk+] broadway: Make Sec-WebSocket-Origin optional



commit da8ff82df578ae5073f07dd8ccb0e7c928dfd774
Author: Alexander Larsson <alexl redhat com>
Date:   Thu Jan 10 22:50:03 2013 +0100

    broadway: Make Sec-WebSocket-Origin optional
    
    Sometimes we get no Origin in the request

 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 3ee706f..86f0053 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);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]