r3207 - trunk/varnish-cache/bin/varnishtest

phk at projects.linpro.no phk at projects.linpro.no
Sun Sep 21 08:47:37 CEST 2008


Author: phk
Date: 2008-09-21 08:47:37 +0200 (Sun, 21 Sep 2008)
New Revision: 3207

Modified:
   trunk/varnish-cache/bin/varnishtest/vtc_http.c
Log:
Add a "resp.bodylen" variable we can expect on, so we can test the
length of a reply in chunked encoding



Modified: trunk/varnish-cache/bin/varnishtest/vtc_http.c
===================================================================
--- trunk/varnish-cache/bin/varnishtest/vtc_http.c	2008-09-19 20:49:30 UTC (rev 3206)
+++ trunk/varnish-cache/bin/varnishtest/vtc_http.c	2008-09-21 06:47:37 UTC (rev 3207)
@@ -57,6 +57,7 @@
 	char			*rxbuf;
 	int			prxbuf;
 	char			*body;
+	char			bodylen[20];
 
 	char			*req[MAX_HDR];
 	char			*resp[MAX_HDR];
@@ -159,6 +160,8 @@
 		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 @@
 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 @@
 			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 @@
 			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);
 }
 
 /**********************************************************************




More information about the varnish-commit mailing list