add compression defeat switch to test client
authorAndy Green <andy@warmcat.com>
Sun, 6 Mar 2011 13:32:53 +0000 (13:32 +0000)
committerAndy Green <andy@warmcat.com>
Sun, 6 Mar 2011 13:32:53 +0000 (13:32 +0000)
Signed-off-by: Andy Green <andy@warmcat.com>
test-server/test-client.c

index 90341d8..4c5dbab 100644 (file)
@@ -29,6 +29,7 @@
 
 static unsigned int opts;
 static int was_closed;
+static int deny_deflate;
 
 /*
  * This demo shows how to connect multiple websockets simultaneously to a
@@ -68,6 +69,16 @@ callback_dumb_increment(struct libwebsocket_context * this,
                fprintf(stderr, "rx %d '%s'\n", (int)len, (char *)in);
                break;
 
+       /* because we are protocols[0] ... */
+
+       case LWS_CALLBACK_CLIENT_CONFIRM_EXTENSION_SUPPORTED:
+               if (strcmp(in, "deflate-stream") == 0)
+                       if (deny_deflate) {
+                               fprintf(stderr, "denied deflate-stream extension\n");
+                               return 1;
+                       }
+               break;
+
        default:
                break;
        }
@@ -169,6 +180,7 @@ static struct option options[] = {
        { "ssl",        no_argument,            NULL, 's' },
        { "killmask",   no_argument,            NULL, 'k' },
        { "version",    required_argument,      NULL, 'v' },
+       { "undeflated", no_argument,            NULL, 'u' },
        { NULL, 0, 0, 0 }
 };
 
@@ -192,7 +204,7 @@ int main(int argc, char **argv)
                goto usage;
 
        while (n >= 0) {
-               n = getopt_long(argc, argv, "v:khsp:", options, NULL);
+               n = getopt_long(argc, argv, "uv:khsp:", options, NULL);
                if (n < 0)
                        continue;
                switch (n) {
@@ -208,6 +220,9 @@ int main(int argc, char **argv)
                case 'v':
                        ietf_version = atoi(optarg);
                        break;
+               case 'u':
+                       deny_deflate = 1;
+                       break;
                case 'h':
                        goto usage;
                }