Don't care for the human-readable part of "HTTP/1.1 101" reply
authorArtem Egorkine <arteme@gmail.com>
Wed, 23 Nov 2011 08:46:24 +0000 (10:46 +0200)
committerAndy Green <andy.green@linaro.org>
Sun, 19 Feb 2012 16:26:17 +0000 (17:26 +0100)
While the protocol specification gives example of the
human-readable message associated with a 101-code reply,
nowhere does it actually enforce it. Ws4py gevent middleware
is known to have a message other than "Switching Protocols".

lib/libwebsockets.c

index f8522b5..6baf2c7 100644 (file)
@@ -1089,8 +1089,8 @@ lws_client_interpret_server_handshake(struct libwebsocket_context *context,
                }
 
                strtolower(wsi->utf8_token[WSI_TOKEN_HTTP].token);
-               if (strcmp(wsi->utf8_token[WSI_TOKEN_HTTP].token,
-                       "101 websocket protocol handshake")) {
+               if (strncmp(wsi->utf8_token[WSI_TOKEN_HTTP].token,
+                                                           "101", 3)) {
                        fprintf(stderr, "libwebsocket_client_handshake "
                                "server sent bad HTTP response '%s'\n",
                                wsi->utf8_token[WSI_TOKEN_HTTP].token);
@@ -1145,8 +1145,7 @@ lws_client_interpret_server_handshake(struct libwebsocket_context *context,
         */
 
        strtolower(wsi->utf8_token[WSI_TOKEN_HTTP].token);
-       if (strcmp(wsi->utf8_token[WSI_TOKEN_HTTP].token,
-                                          "101 switching protocols")) {
+       if (strncmp(wsi->utf8_token[WSI_TOKEN_HTTP].token, "101", 3)) {
                fprintf(stderr, "libwebsocket_client_handshake "
                                "server sent bad HTTP response '%s'\n",
                                 wsi->utf8_token[WSI_TOKEN_HTTP].token);