From a3a6f3af0982f579526948860653a09d9eb9c090 Mon Sep 17 00:00:00 2001 From: phk Date: Sun, 21 Sep 2008 06:47:37 +0000 Subject: [PATCH] Add a "resp.bodylen" variable we can expect on, so we can test the 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 | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/varnish-cache/bin/varnishtest/vtc_http.c b/varnish-cache/bin/varnishtest/vtc_http.c index 23450a65..e77069a9 100644 --- a/varnish-cache/bin/varnishtest/vtc_http.c +++ b/varnish-cache/bin/varnishtest/vtc_http.c @@ -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); } /********************************************************************** -- 2.39.5