]> err.no Git - varnish/commitdiff
Make -body automatically create a Content-Length header in txresp and txreq.
authorphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Thu, 26 Jun 2008 09:45:29 +0000 (09:45 +0000)
committerphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Thu, 26 Jun 2008 09:45:29 +0000 (09:45 +0000)
For lowerlevel syntax based tests, we can revert to send and chunked.

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

varnish-cache/bin/varnishtest/tests/a00006.vtc
varnish-cache/bin/varnishtest/tests/a00007.vtc
varnish-cache/bin/varnishtest/tests/c00004.vtc
varnish-cache/bin/varnishtest/tests/c00005.vtc
varnish-cache/bin/varnishtest/tests/r00255.vtc
varnish-cache/bin/varnishtest/vtc_http.c

index 6af785a48f869acf50e46cfd65f96a5a7f8179ba..29d1e1644c7237e5272457c82a77213c6fa6d6bd 100644 (file)
@@ -8,7 +8,6 @@ server s1 -listen 127.0.0.1:9080 {
        expect req.proto == HTTP/1.0
        expect req.url == "/foo"
        txresp -proto HTTP/1.2 -status 201 -msg Foo \
-               -hdr "Content-Length: 10" \
                -body "987654321\n"
 }
 
@@ -16,7 +15,6 @@ server s1 -start
 
 client c1 -connect 127.0.0.1:9080 {
        txreq -req PUT -proto HTTP/1.0 -url /foo \
-               -hdr "Content-Length: 10" \
                -body "123456789\n"
        rxresp
        expect resp.proto == HTTP/1.2
index 5040ae98603c08916f681fd0f945a7faa68c433f..e9d8eecff67456fb2f04af1b08586e67c51e844d 100644 (file)
@@ -5,20 +5,18 @@ test "TCP reuse"
 server s1 -listen 127.0.0.1:9080 {
        rxreq
        expect req.url == "/1"
-       txresp -hdr "Content-Length: 10" -body "123456789\n"
+       txresp -body "123456789\n"
        rxreq
        expect req.url == "/2"
-       txresp -hdr "Content-Length: 10" -body "987654321\n"
+       txresp -body "987654321\n"
 }
 
 server s1 -start 
 
 client c1 -connect 127.0.0.1:9080 {
-       txreq -url "/1" -req "POST" \
-           -hdr "Content-Length: 10" -body "abcdefghi\n"
+       txreq -url "/1" -req "POST" -body "abcdefghi\n"
        rxresp
-       txreq -url "/2" -req "POST" \
-           -hdr "Content-Length: 10" -body "ihgfedcba\n"
+       txreq -url "/2" -req "POST" -body "ihgfedcba\n"
        rxresp
 }
 
index 62780bb6f624133154b15d32846dadac13c3c0f3..ea712102a2443211cd0030ab0529192768655145 100644 (file)
@@ -7,15 +7,15 @@ varnish v1 -arg "-b 127.0.0.1:9080" -start
 server s1 {
        rxreq
        expect req.http.foobar == "1"
-       txresp -hdr "Vary: Foobar" -hdr "Snafu: 1" -hdr "Content-Length: 5" -body "1111\n"
+       txresp -hdr "Vary: Foobar" -hdr "Snafu: 1" -body "1111\n"
        rxreq
        expect req.http.foobar == "2"
-       txresp -hdr "Vary: Foobar" -hdr "Snafu: 2" -hdr "Content-Length: 5" -body "2222\n"
+       txresp -hdr "Vary: Foobar" -hdr "Snafu: 2" -body "2222\n"
        rxreq
        expect req.http.foobar == "3"
-       txresp -hdr "Vary: Foobar" -hdr "Snafu: 3" -hdr "Content-Length: 5" -body "3333\n"
+       txresp -hdr "Vary: Foobar" -hdr "Snafu: 3" -body "3333\n"
        rxreq
-       txresp -hdr "Vary: Foobar" -hdr "Snafu: 4" -hdr "Content-Length: 5" -body "4444\n"
+       txresp -hdr "Vary: Foobar" -hdr "Snafu: 4" -body "4444\n"
 } -start
 
 client c1 {
index ea0f4c1c016bd0b56934349ac0405d371031e18d..3edd216b541a9611a503addce7594063547ef3ca 100644 (file)
@@ -5,10 +5,10 @@ test "Test simple ACL"
 server s1 {
        rxreq
        expect req.url == "/"
-       txresp -hdr "Content-Length: 5" -body "1111\n"
+       txresp -body "1111\n"
        rxreq
        expect req.url == "foo"
-       txresp -hdr "Content-Length: 5" -body "2222\n"
+       txresp -body "2222\n"
 } -start
 
 varnish v1 -vcl+backend {
index 0c757a98a7a82a7d55f185057e839ec1079630fe..67b01980d5b292b16c64b85d6471461cc6a155a8 100644 (file)
@@ -6,7 +6,6 @@ server s1 {
        rxreq 
        txresp \
            -hdr "Date: Thu, 19 Jun 2008 21:14:49 GMT" \
-           -hdr "Content-Length: 7" \
            -hdr "Expires: Thu, 19 Jun 2008 21:14:49 GMT" \
            -hdr "Last-Modified: Sun, 27 Nov 2005 05:41:47 GMT" \
            -hdr "Cache-Control: max-age =0" \
index 7d02a0fe93ea3b5675c8e5df9f353a708e46c034..c9eb72f8eda2628c25398ea56f9639c7f4a8824e 100644 (file)
@@ -359,7 +359,6 @@ cmd_http_txresp(CMD_ARGS)
        const char *status = "200";
        const char *msg = "Ok";
        const char *body = NULL;
-       int dohdr = 0;
 
        (void)cmd;
        CAST_OBJ_NOTNULL(hp, priv, HTTP_MAGIC);
@@ -371,46 +370,42 @@ cmd_http_txresp(CMD_ARGS)
 
        for(; *av != NULL; av++) {
                if (!strcmp(*av, "-proto")) {
-                       AZ(dohdr);
                        proto = av[1];
                        av++;
-                       continue;
-               }
-               if (!strcmp(*av, "-status")) {
-                       AZ(dohdr);
+               } else if (!strcmp(*av, "-status")) {
                        status = av[1];
                        av++;
-                       continue;
-               }
-               if (!strcmp(*av, "-msg")) {
-                       AZ(dohdr);
+               } else if (!strcmp(*av, "-msg")) {
                        msg = av[1];
                        av++;
                        continue;
-               }
-               if (!strcmp(*av, "-body")) {
-                       body = av[1];
-                       av++;
-                       continue;
-               }
+               } else
+                       break;
+       }
+
+       vsb_printf(hp->vsb, "%s %s %s%s", proto, status, msg, nl);
+
+       for(; *av != NULL; av++) {
                if (!strcmp(*av, "-hdr")) {
-                       if (dohdr == 0) {
-                               vsb_printf(hp->vsb, "%s %s %s%s", 
-                                   proto, status, msg, nl);
-                               dohdr = 1;
-                       }
                        vsb_printf(hp->vsb, "%s%s", av[1], nl);
                        av++;
-                       continue;
-               }
-               fprintf(stderr, "Unknown http txreq spec: %s\n", *av);
-               exit (1);
+               } else 
+                       break;
        }
-       if (dohdr == 0) {
-               vsb_printf(hp->vsb, "%s %s %s%s", 
-                   proto, status, msg, nl);
-               dohdr = 1;
+       for(; *av != NULL; av++) {
+               if (!strcmp(*av, "-body")) {
+                       AZ(body);
+                       body = av[1];
+                       av++;
+               } else
+                       break;
+       }
+       if (*av != NULL) {
+               fprintf(stderr, "Unknown http txresp spec: %s\n", *av);
+               exit (1);
        }
+       if (body != NULL) 
+               vsb_printf(hp->vsb, "Content-Length: %d%s", strlen(body), nl);
        vsb_cat(hp->vsb, nl);
        if (body != NULL) {
                vsb_cat(hp->vsb, body);
@@ -456,7 +451,6 @@ cmd_http_txreq(CMD_ARGS)
        const char *url = "/";
        const char *proto = "HTTP/1.1";
        const char *body = NULL;
-       int dohdr = 0;
 
        (void)cmd;
        CAST_OBJ_NOTNULL(hp, priv, HTTP_MAGIC);
@@ -468,46 +462,39 @@ cmd_http_txreq(CMD_ARGS)
 
        for(; *av != NULL; av++) {
                if (!strcmp(*av, "-url")) {
-                       AZ(dohdr);
                        url = av[1];
                        av++;
-                       continue;
-               }
-               if (!strcmp(*av, "-proto")) {
-                       AZ(dohdr);
+               } else if (!strcmp(*av, "-proto")) {
                        proto = av[1];
                        av++;
-                       continue;
-               }
-               if (!strcmp(*av, "-req")) {
-                       AZ(dohdr);
+               } else if (!strcmp(*av, "-req")) {
                        req = av[1];
                        av++;
-                       continue;
-               }
+               } else
+                       break;
+       }
+       vsb_printf(hp->vsb, "%s %s %s%s", req, url, proto, nl);
+       for(; *av != NULL; av++) {
                if (!strcmp(*av, "-hdr")) {
-                       if (dohdr == 0) {
-                               vsb_printf(hp->vsb, "%s %s %s%s", 
-                                   req, url, proto, nl);
-                               dohdr = 1;
-                       }
                        vsb_printf(hp->vsb, "%s%s", av[1], nl);
                        av++;
-                       continue;
-               }
+               } else
+                       break;
+       }
+       for(; *av != NULL; av++) {
                if (!strcmp(*av, "-body")) {
+                       AZ(body);
                        body = av[1];
                        av++;
-                       continue;
-               }
+               } else
+                       break;
+       }
+       if (*av != NULL) {
                fprintf(stderr, "Unknown http txreq spec: %s\n", *av);
                exit (1);
        }
-       if (dohdr == 0) {
-               vsb_printf(hp->vsb, "%s %s %s%s", 
-                   req, url, proto, nl);
-               dohdr = 1;
-       }
+       if (body != NULL) 
+               vsb_printf(hp->vsb, "Content-Length: %d%s", strlen(body), nl);
        vsb_cat(hp->vsb, nl);
        if (body != NULL) {
                vsb_cat(hp->vsb, body);