[asterisk-commits] dlee: branch dlee/ASTERISK-22441-websocket-pickiness r398509 - /team/dlee/AST...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Sep 6 10:31:57 CDT 2013


Author: dlee
Date: Fri Sep  6 10:31:54 2013
New Revision: 398509

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=398509
Log:
Fix WebSocket response when subprotocol isn't specified.

Modified:
    team/dlee/ASTERISK-22441-websocket-pickiness/res/res_http_websocket.c

Modified: team/dlee/ASTERISK-22441-websocket-pickiness/res/res_http_websocket.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/ASTERISK-22441-websocket-pickiness/res/res_http_websocket.c?view=diff&rev=398509&r1=398508&r2=398509
==============================================================================
--- team/dlee/ASTERISK-22441-websocket-pickiness/res/res_http_websocket.c (original)
+++ team/dlee/ASTERISK-22441-websocket-pickiness/res/res_http_websocket.c Fri Sep  6 10:31:54 2013
@@ -645,11 +645,25 @@
 		fprintf(ser->f, "HTTP/1.1 101 Switching Protocols\r\n"
 			"Upgrade: %s\r\n"
 			"Connection: Upgrade\r\n"
-			"Sec-WebSocket-Accept: %s\r\n"
-			"Sec-WebSocket-Protocol: %s\r\n\r\n",
+			"Sec-WebSocket-Accept: %s\r\n",
 			upgrade,
-			base64,
-			protocol_handler->name);
+			base64);
+
+		/* RFC 6455, Section 4.1:
+		 *
+		 * 6. If the response includes a |Sec-WebSocket-Protocol| header
+		 *    field and this header field indicates the use of a
+		 *    subprotocol that was not present in the client's handshake
+		 *    (the server has indicated a subprotocol not requested by
+		 *    the client), the client MUST _Fail the WebSocket
+		 *    Connection_.
+		 */
+		if (protocol) {
+			fprintf(ser->f, "Sec-WebSocket-Protocol: %s\r\n",
+				protocol);
+		}
+
+		fprintf(ser->f, "\r\n");
 	} else {
 
 		/* Specification defined in http://tools.ietf.org/html/draft-hixie-thewebsocketprotocol-75 or completely unknown */




More information about the asterisk-commits mailing list