r3291 - trunk/varnish-cache/bin/varnishtest
phk at projects.linpro.no
phk at projects.linpro.no
Sat Oct 11 13:27:56 CEST 2008
Author: phk
Date: 2008-10-11 13:27:56 +0200 (Sat, 11 Oct 2008)
New Revision: 3291
Modified:
trunk/varnish-cache/bin/varnishtest/vtc_http.c
Log:
Handle HTTP1.0 style "until EOF" data transmissions for 200 responses.
Modified: trunk/varnish-cache/bin/varnishtest/vtc_http.c
===================================================================
--- trunk/varnish-cache/bin/varnishtest/vtc_http.c 2008-10-11 10:42:05 UTC (rev 3290)
+++ trunk/varnish-cache/bin/varnishtest/vtc_http.c 2008-10-11 11:27:56 UTC (rev 3291)
@@ -305,8 +305,8 @@
* Receive another character
*/
-static void
-http_rxchar(struct http *hp, int n)
+static int
+http_rxchar_eof(struct http *hp, int n)
{
int i;
struct pollfd pfd[1];
@@ -319,19 +319,31 @@
assert(i > 0);
assert(hp->prxbuf < hp->nrxbuf);
i = read(hp->fd, hp->rxbuf + hp->prxbuf, n);
+ if (i == 0)
+ return (i);
assert(i > 0);
hp->prxbuf += i;
hp->rxbuf[hp->prxbuf] = '\0';
n -= i;
}
+ return (1);
}
+static void
+http_rxchar(struct http *hp, int n)
+{
+ int i;
+
+ i = http_rxchar_eof(hp, n);
+ assert(i > 0);
+}
+
/**********************************************************************
* Swallow a HTTP message body
*/
static void
-http_swallow_body(struct http *hp, char * const *hh)
+http_swallow_body(struct http *hp, char * const *hh, int body)
{
char *p, *q;
int i, l, ll;
@@ -344,7 +356,8 @@
hp->body = q = hp->rxbuf + hp->prxbuf;
http_rxchar(hp, l);
vtc_dump(hp->vl, 4, "body", hp->body);
- ll = l;
+ sprintf(hp->bodylen, "%d", l);
+ return;
}
p = http_find_header(hh, "transfer-encoding");
if (p != NULL && !strcmp(p, "chunked")) {
@@ -374,7 +387,17 @@
break;
}
vtc_dump(hp->vl, 4, "body", hp->body);
+ sprintf(hp->bodylen, "%d", ll);
+ return;
}
+ if (body) {
+ hp->body = q = hp->rxbuf + hp->prxbuf;
+ do {
+ i = http_rxchar_eof(hp, 1);
+ ll += i;
+ } while (i > 0);
+ vtc_dump(hp->vl, 4, "rxeof", hp->body);
+ }
sprintf(hp->bodylen, "%d", ll);
}
@@ -433,7 +456,11 @@
vtc_log(hp->vl, 3, "rxresp");
http_rxhdr(hp);
http_splitheader(hp, 0);
- http_swallow_body(hp, hp->resp);
+ if (!strcmp(hp->resp[1], "200"))
+ http_swallow_body(hp, hp->resp, 1);
+ else
+ http_swallow_body(hp, hp->resp, 0);
+ vtc_log(hp->vl, 4, "bodylen = %s", hp->bodylen);
}
/**********************************************************************
@@ -531,7 +558,8 @@
vtc_log(hp->vl, 3, "rxreq");
http_rxhdr(hp);
http_splitheader(hp, 1);
- http_swallow_body(hp, hp->req);
+ http_swallow_body(hp, hp->req, 0);
+ vtc_log(hp->vl, 4, "bodylen = %s", hp->bodylen);
}
/**********************************************************************
More information about the varnish-commit
mailing list