]> err.no Git - varnish/commitdiff
Add a "resp.bodylen" variable we can expect on, so we can test the
authorphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Sun, 21 Sep 2008 06:47:37 +0000 (06:47 +0000)
committerphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Sun, 21 Sep 2008 06:47:37 +0000 (06:47 +0000)
length of a reply in chunked encoding

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

varnish-cache/bin/varnishtest/vtc_http.c

index 23450a652bf303006dc38f70eb2dad47cfcd90ae..e77069a996b44ba145391fe52b110eb99fc69f65 100644 (file)
@@ -57,6 +57,7 @@ struct http {
        char                    *rxbuf;
        int                     prxbuf;
        char                    *body;
+       char                    bodylen[20];
 
        char                    *req[MAX_HDR];
        char                    *resp[MAX_HDR];
@@ -159,6 +160,8 @@ cmd_var_resolve(struct http *hp, char *spec)
                return(hp->resp[1]);
        if (!strcmp(spec, "resp.msg"))
                return(hp->resp[2]);
+       if (!strcmp(spec, "resp.bodylen"))
+               return(hp->bodylen);
        if (!memcmp(spec, "req.http.", 9)) {
                hh = hp->req;
                hdr = spec + 9;
@@ -330,15 +333,17 @@ static void
 http_swallow_body(struct http *hp, char * const *hh)
 {
        char *p, *q;
-       int i, l;
+       int i, l, ll;
        
 
+       ll = 0;
        p = http_find_header(hh, "content-length");
        if (p != NULL) {
                l = strtoul(p, NULL, 0);
                hp->body = q = hp->rxbuf + hp->prxbuf;
                http_rxchar(hp, l);
                vtc_dump(hp->vl, 4, "body", hp->body);
+               ll = l;
        }
        p = http_find_header(hh, "transfer-encoding");
        if (p != NULL && !strcmp(p, "chunked")) {
@@ -354,6 +359,7 @@ http_swallow_body(struct http *hp, char * const *hh)
                        assert(*q == '\0' || vct_islws(*q));
                        hp->prxbuf = l;
                        if (i > 0) {
+                               ll += i;
                                http_rxchar(hp, i);
                                vtc_dump(hp->vl, 4, "chunk", hp->rxbuf + l);
                        }
@@ -362,11 +368,13 @@ http_swallow_body(struct http *hp, char * const *hh)
                        assert(vct_iscrlf(hp->rxbuf[l]));
                        assert(vct_iscrlf(hp->rxbuf[l + 1]));
                        hp->prxbuf = l;
+                       hp->rxbuf[l] = '\0';
                        if (i == 0)
                                break;
                }
                vtc_dump(hp->vl, 4, "body", hp->body);
        }
+       sprintf(hp->bodylen, "%d", ll);
 }
 
 /**********************************************************************