diff --git a/gdk/broadway/broadway.js b/gdk/broadway/broadway.js
index 357620e..609f459 100644
--- a/gdk/broadway/broadway.js
+++ b/gdk/broadway/broadway.js
@@ -2769,37 +2769,42 @@ function connect()
 	    useToplevelWindows = true;
     }
 
-    if ("WebSocket" in window) {
-	var loc = window.location.toString().replace("http:", "ws:");
-	loc = loc.substr(0, loc.lastIndexOf('/')) + "/socket";
-	var ws = new WebSocket(loc, "broadway");
-	ws.onopen = function() {
-	    inputSocket = ws;
-	    var w, h;
-	    if (useToplevelWindows) {
-		w = window.screen.width;
-		h = window.screen.height;
-	    } else {
-		w = window.innerWidth;
-		h = window.innerHeight;
-		window.onresize = function(ev) {
-		    var w, h;
-		    w = window.innerWidth;
-		    h = window.innerHeight;
-		    sendInput ("d", [w, h]);
-		};
-	    }
-	    sendInput ("d", [w, h]);
-	};
-	ws.onclose = function() {
-	    inputSocket = null;
-	};
-	ws.onmessage = function(event) {
-	    handleMessage(event.data);
-	};
+    var loc = window.location.toString().replace("http:", "ws:");
+    loc = loc.substr(0, loc.lastIndexOf('/')) + "/socket";
+    var ws = null;
+    if ("MozWebSocket" in window) {
+	ws = new MozWebSocket(loc);
+    } else if ("WebSocket" in window) {
+        ws = new WebSocket(loc, "broadway");
     } else {
 	alert("WebSocket not supported, input will not work!");
+        return;
     }
+
+    ws.onopen = function() {
+	inputSocket = ws;
+	var w, h;
+	if (useToplevelWindows) {
+	  w = window.screen.width;
+	  h = window.screen.height;
+	} else {
+	  w = window.innerWidth;
+	  h = window.innerHeight;
+	  window.onresize = function(ev) {
+	    var w, h;
+	    w = window.innerWidth;
+	    h = window.innerHeight;
+            sendInput ("d", [w, h]);
+	  };
+	}
+	sendInput ("d", [w, h]);
+    };
+    ws.onclose = function() {
+	inputSocket = null;
+    };
+    ws.onmessage = function(event) {
+	handleMessage(event.data);
+    };
     setupDocument(document);
     window.onunload = function (ev) {
 	for (var i = 0; i < toplevelWindows.length; i++)
diff --git a/gdk/broadway/gdkdisplay-broadway.c b/gdk/broadway/gdkdisplay-broadway.c
index 6a8ca21..47275e1 100644
--- a/gdk/broadway/gdkdisplay-broadway.c
+++ b/gdk/broadway/gdkdisplay-broadway.c
@@ -537,6 +542,55 @@ send_error (HttpRequest *request,
   http_request_free (request);
 }
 
+
+gchar *hex_string_to_ascii_string(gchar *string)
+{
+	gchar *buffer;
+	int count = 0;
+
+	buffer = g_malloc(strlen(string)+1);
+	while (*string) {
+		int value = 0;
+		int c = *string;
+		if ((c>='0') && (c<='9'))
+			value = c-'0';
+		if ((c>='A') && (c<='F'))
+			value = 10+(c-'A');
+		if ((c>='a') && (c<='f'))
+			value = 10+(c-'a');
+		string++;
+		if (! *string)
+			break;
+		c = *string;
+		value = value << 4;
+		if ((c>='0') && (c<='9'))
+			value |= c-'0';
+		if ((c>='A') && (c<='F'))
+			value |= 10+c-'A';
+		if ((c>='a') && (c<='f'))
+			value |= 10+c-'a';
+		buffer[count++] = value;
+		string++;
+	}
+	buffer[count++] = '\0';
+	return buffer;
+}
+
+gchar* generate_handshake_response_wsietf_v7 (gchar * key) {
+	gchar* full_key = g_strconcat (key, "258EAFA5-E914-47DA-95CA-C5AB0DC85B11", NULL);
+	gchar* sha1_result = g_compute_checksum_for_data (G_CHECKSUM_SHA1, 
+                                                          full_key,
+                                                          strlen(full_key));
+	gchar* decoded = hex_string_to_ascii_string (sha1_result);
+	gchar* result = g_base64_encode (decoded, (int)strlen(sha1_result) / 2);
+
+	g_free (full_key);
+	g_free (sha1_result);
+	g_free (decoded);
+
+	return result;
+}
+
 static void
 start_input (HttpRequest *request)
 {
@@ -556,6 +610,7 @@ start_input (HttpRequest *request)
   const void *data_buffer;
   gsize data_buffer_size;
   GInputStream *in;
+  char *key_v7;
 
   broadway_display = GDK_BROADWAY_DISPLAY (request->display);
 
@@ -613,38 +669,53 @@ start_input (HttpRequest *request)
 	{
 	  host = p;
 	}
+      else if ((p = parse_line (lines[i], "Sec-WebSocket-Key")))
+	{
+	  key_v7 = p;
+	}
     }
 
-  if (num_key1 != 1 || num_key2 != 1 || origin == NULL || host == NULL)
+  if ((num_key1 != 1 || num_key2 != 1 || origin == NULL || host == NULL) && (key_v7 == NULL))
     {
       g_strfreev (lines);
       send_error (request, 400, "Bad websocket request");
       return;
     }
 
-  challenge[0] = (key1 >> 24) & 0xff;
-  challenge[1] = (key1 >> 16) & 0xff;
-  challenge[2] = (key1 >>  8) & 0xff;
-  challenge[3] = (key1 >>  0) & 0xff;
-  challenge[4] = (key2 >> 24) & 0xff;
-  challenge[5] = (key2 >> 16) & 0xff;
-  challenge[6] = (key2 >>  8) & 0xff;
-  challenge[7] = (key2 >>  0) & 0xff;
-
-  if (!g_input_stream_read_all (G_INPUT_STREAM (request->data), challenge+8, 8, NULL, NULL, NULL))
+  if (key_v7 != NULL)
     {
-      g_strfreev (lines);
-      send_error (request, 400, "Bad websocket request");
-      return;
+      char* accept = generate_handshake_response_wsietf_v7 (key_v7);
+      res = g_strdup_printf ("HTTP/1.1 101 Switching Protocols\r\n"
+			 "Upgrade: websocket\r\n"
+			 "Connection: Upgrade\r\n"
+			 "Sec-WebSocket-Accept: %s\r\n"
+			 "\r\n", accept);
     }
-
-  checksum = g_checksum_new (G_CHECKSUM_MD5);
-  g_checksum_update (checksum, challenge, 16);
-  len = 16;
-  g_checksum_get_digest (checksum, challenge, &len);
-  g_checksum_free (checksum);
-
-  res = g_strdup_printf ("HTTP/1.1 101 WebSocket Protocol Handshake\r\n"
+  else
+    {
+      challenge[0] = (key1 >> 24) & 0xff;
+      challenge[1] = (key1 >> 16) & 0xff;
+      challenge[2] = (key1 >>  8) & 0xff;
+      challenge[3] = (key1 >>  0) & 0xff;
+      challenge[4] = (key2 >> 24) & 0xff;
+      challenge[5] = (key2 >> 16) & 0xff;
+      challenge[6] = (key2 >>  8) & 0xff;
+      challenge[7] = (key2 >>  0) & 0xff;
+
+      if (!g_input_stream_read_all (G_INPUT_STREAM (request->data), challenge+8, 8, NULL, NULL, NULL))
+        {
+          g_strfreev (lines);
+          send_error (request, 400, "Bad websocket request");
+          return;
+        }
+
+      checksum = g_checksum_new (G_CHECKSUM_MD5);
+      g_checksum_update (checksum, challenge, 16);
+      len = 16;
+      g_checksum_get_digest (checksum, challenge, &len);
+      g_checksum_free (checksum);
+
+      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"
@@ -652,12 +723,17 @@ start_input (HttpRequest *request)
 			 "Sec-WebSocket-Protocol: broadway\r\n"
 			 "\r\n",
 			 origin, host);
+    }
 
   g_output_stream_write_all (g_io_stream_get_output_stream (G_IO_STREAM (request->connection)),
 			     res, strlen (res), NULL, NULL, NULL);
   g_free (res);
-  g_output_stream_write_all (g_io_stream_get_output_stream (G_IO_STREAM (request->connection)),
-			     challenge, 16, NULL, NULL, NULL);
+
+  if (key_v7 == NULL)
+    {
+      g_output_stream_write_all (g_io_stream_get_output_stream (G_IO_STREAM (request->connection)),
+			         challenge, 16, NULL, NULL, NULL);
+    }
 
   input = g_new0 (BroadwayInput, 1);
 
