]> err.no Git - varnish/commitdiff
Add -bodylen which creates a synthetic body of the specified length.
authorphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Mon, 8 Sep 2008 17:34:16 +0000 (17:34 +0000)
committerphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Mon, 8 Sep 2008 17:34:16 +0000 (17:34 +0000)
The generated body is the classic drum-printer test pattern:

!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_\n
"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`\n
#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`a\n
$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`ab\n

The last char is always a \n

git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@3173 d4fa192b-c00b-0410-8231-f00ffab90ce4

varnish-cache/bin/varnishtest/vtc_http.c

index b8677f2fabf51f1dc530dee1365a2dcf17bffaf4..23450a652bf303006dc38f70eb2dad47cfcd90ae 100644 (file)
@@ -65,6 +65,41 @@ struct http {
 /* XXX: we may want to vary this */
 static const char *nl = "\r\n";
 
+/**********************************************************************
+ * Generate a synthetic body
+ */
+
+static const char *
+synth_body(const char *len)
+{
+       int i, j, k, l;
+       char *b;
+       
+       
+       AN(len);
+       i = strtoul(len, NULL, 0);
+       assert(i > 0);
+       b = malloc(i + 1);
+       AN(b);
+       l = k = '!';
+       for (j = 0; j < i; j++) {
+               if ((j % 64) == 63) {
+                       b[j] = '\n';
+                       k++;
+                       if (k == '~')
+                               k = '!';
+                       l = k;
+               } else {
+                       b[j] = l++;
+                       if (l == '~')
+                               l = '!';
+               }
+       }
+       b[i - 1] = '\n';
+       b[i] = '\0';
+       return (b);
+}
+
 /**********************************************************************
  * Finish and write the vsb to the fd
  */
@@ -441,6 +476,10 @@ cmd_http_txresp(CMD_ARGS)
                        AZ(body);
                        body = av[1];
                        av++;
+               } else if (!strcmp(*av, "-bodylen")) {
+                       AZ(body);
+                       body = synth_body(av[1]);
+                       av++;
                } else
                        break;
        }
@@ -530,6 +569,10 @@ cmd_http_txreq(CMD_ARGS)
                        AZ(body);
                        body = av[1];
                        av++;
+               } else if (!strcmp(*av, "-bodylen")) {
+                       AZ(body);
+                       body = synth_body(av[1]);
+                       av++;
                } else
                        break;
        }