fix-hostname-to-be-server-name--allow-switches-in-any-order.patch
authorAndy Green <andy@warmcat.com>
Sun, 6 Feb 2011 17:42:06 +0000 (17:42 +0000)
committerAndy Green <andy@warmcat.com>
Sun, 6 Feb 2011 17:42:06 +0000 (17:42 +0000)
Signed-off-by: Andy Green <andy@warmcat.com>
lib/client-handshake.c
lib/libwebsockets.c
test-server/test-client.c

index bb46a7a..a95eb52 100644 (file)
@@ -401,6 +401,7 @@ libwebsocket_client_connect(struct libwebsocket_context *this,
                                                            protocol != NULL)) {
                fprintf(stderr, "libwebsocket_client_handshake "
                                                "missing required header(s)\n");
+               pkt[len] = '\0';
                fprintf(stderr, "%s", pkt);
                goto bail2;
        }
index c88715e..7f11164 100644 (file)
@@ -672,6 +672,8 @@ libwebsocket_create_context(int port,
        strncpy(this->canonical_hostname, he->h_name,
                                           sizeof this->canonical_hostname - 1);
        this->canonical_hostname[sizeof this->canonical_hostname - 1] = '\0';
+       fprintf(stderr, "  canonical hostname = '%s'\n",
+                                       this->canonical_hostname);
 
        /* split the proxy ads:port if given */
 
index e03d115..59595e0 100644 (file)
@@ -168,7 +168,7 @@ int main(int argc, char **argv)
        int port = 7681;
        int use_ssl = 0;
        struct libwebsocket_context *context;
-       const char *address = argv[1];
+       const char *address;
        struct libwebsocket *wsi_dumb;
        struct libwebsocket *wsi_mirror;
 
@@ -200,6 +200,11 @@ int main(int argc, char **argv)
                }
        }
 
+       if (optind >= argc)
+               goto usage;
+
+       address = argv[optind];
+
        /*
         * create the websockets context.  This tracks open connections and
         * knows how to route any traffic and which protocol version to use,
@@ -219,7 +224,7 @@ int main(int argc, char **argv)
        /* create a client websocket using dumb increment protocol */
 
        wsi_dumb = libwebsocket_client_connect(context, address, port, use_ssl,
-                       "/", libwebsocket_canonical_hostname(context), "origin",
+                       "/", argv[optind], argv[optind],
                                       protocols[PROTOCOL_DUMB_INCREMENT].name);
 
        if (wsi_dumb == NULL) {
@@ -230,7 +235,7 @@ int main(int argc, char **argv)
        /* create a client websocket using mirror protocol */
 
        wsi_mirror = libwebsocket_client_connect(context, address, port,
-            use_ssl,  "/", libwebsocket_canonical_hostname(context), "origin",
+            use_ssl,  "/", argv[optind], argv[optind],
                                       protocols[PROTOCOL_LWS_MIRROR].name);
 
        if (wsi_mirror == NULL) {