r1997 - trunk/varnish-cache/bin/varnishd

phk at projects.linpro.no phk at projects.linpro.no
Sun Sep 23 15:46:43 CEST 2007


Author: phk
Date: 2007-09-23 15:46:43 +0200 (Sun, 23 Sep 2007)
New Revision: 1997

Modified:
   trunk/varnish-cache/bin/varnishd/cache.h
   trunk/varnish-cache/bin/varnishd/cache_fetch.c
   trunk/varnish-cache/bin/varnishd/cache_http.c
Log:
Fix another cornercase that fell out as part of the pass->fetch rewrite:

If we pass a HEAD request, we should not rewrite it to GET and not expect
a body either.



Modified: trunk/varnish-cache/bin/varnishd/cache.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache.h	2007-09-23 13:22:11 UTC (rev 1996)
+++ trunk/varnish-cache/bin/varnishd/cache.h	2007-09-23 13:46:43 UTC (rev 1997)
@@ -463,6 +463,7 @@
 int http_GetHdr(struct http *hp, const char *hdr, char **ptr);
 int http_GetHdrField(struct http *hp, const char *hdr, const char *field, char **ptr);
 int http_GetStatus(struct http *hp);
+const char *http_GetReq(struct http *hp);
 const char *http_GetProto(struct http *hp);
 int http_HdrIs(struct http *hp, const char *hdr, const char *val);
 int http_GetTail(struct http *hp, unsigned len, char **b, char **e);

Modified: trunk/varnish-cache/bin/varnishd/cache_fetch.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_fetch.c	2007-09-23 13:22:11 UTC (rev 1996)
+++ trunk/varnish-cache/bin/varnishd/cache_fetch.c	2007-09-23 13:46:43 UTC (rev 1997)
@@ -263,7 +263,7 @@
 	struct http *hp, *hp2;
 	struct storage *st;
 	struct bereq *bereq;
-	int len, mklen;
+	int len, mklen, is_get;
 
 	CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
 	CHECK_OBJ_NOTNULL(sp->wrk, WORKER_MAGIC);
@@ -272,6 +272,7 @@
 	w = sp->wrk;
 	bereq = sp->bereq;
 	hp = bereq->http;
+	is_get = !strcasecmp(http_GetReq(hp), "get");
 
 	sp->obj->xid = sp->xid;
 
@@ -341,7 +342,9 @@
 	/* Determine if we have a body or not */
 	cls = 0;
 	mklen = 0;
-	if (http_GetHdr(hp, H_Content_Length, &b)) {
+	if (!is_get) {
+		/* nothing */
+	} else if (http_GetHdr(hp, H_Content_Length, &b)) {
 		cls = fetch_straight(sp, vc->fd, hp, b);
 		mklen = 1;
 	} else if (http_HdrIs(hp, H_Transfer_Encoding, "chunked")) {

Modified: trunk/varnish-cache/bin/varnishd/cache_http.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_http.c	2007-09-23 13:22:11 UTC (rev 1996)
+++ trunk/varnish-cache/bin/varnishd/cache_http.c	2007-09-23 13:46:43 UTC (rev 1997)
@@ -388,6 +388,13 @@
 	return (hp->hd[HTTP_HDR_PROTO].b);
 }
 
+const char *
+http_GetReq(struct http *hp)
+{
+	AN(hp->hd[HTTP_HDR_REQ].b);
+	return (hp->hd[HTTP_HDR_REQ].b);
+}
+
 /*--------------------------------------------------------------------
  * Dissect the headers of the HTTP protocol message.
  * Detect conditionals (headers which start with '^[Ii][Ff]-')
@@ -802,7 +809,8 @@
         hp = bereq->http;
         hp->logtag = HTTP_Tx;
 
-	http_copyreq(hp, sp->http, how == HTTPH_R_PIPE);
+	http_copyreq(hp, sp->http,
+	    (how == HTTPH_R_PIPE) || (how == HTTPH_R_PASS));
 	http_FilterFields(sp->wrk, sp->fd, hp, sp->http, how);
 	http_PrintfHeader(sp->wrk, sp->fd, hp, "X-Varnish: %u", sp->xid);
 	http_PrintfHeader(sp->wrk, sp->fd, hp,




More information about the varnish-commit mailing list