Mailing List Archive

r1177 - in branches/1.0: . bin/varnishd
Author: des
Date: 2006-10-18 16:27:06 +0200 (Wed, 18 Oct 2006)
New Revision: 1177

Modified:
branches/1.0/
branches/1.0/bin/varnishd/cache.h
branches/1.0/bin/varnishd/cache_http.c
branches/1.0/bin/varnishd/cache_pass.c
Log:
r32802 at cat (orig r1138): des | 2006-10-05 13:57:35 +0200
RFC 2616 says "All 1xx (informational), 204 (no content), and 304 (not
modified) responses MUST NOT include a message-body," so
Content-Length: is not needed in these cases (and Apache does indeed
not include it). This causes PassBody() to call pass_straight() with
a NULL length argument, which waits until the connection is closed by
the server. PassBody() should not call pass_*() at all for responses
that are known to be bodyless.

Submitted by: Dagfinn Ilmari Manns?ker <ilmari at ping.uio.no>




Property changes on: branches/1.0
___________________________________________________________________
Name: svk:merge
- d4fa192b-c00b-0410-8231-f00ffab90ce4:/trunk/varnish-cache:1137
+ d4fa192b-c00b-0410-8231-f00ffab90ce4:/trunk/varnish-cache:1138

Modified: branches/1.0/bin/varnishd/cache.h
===================================================================
--- branches/1.0/bin/varnishd/cache.h 2006-10-18 14:27:05 UTC (rev 1176)
+++ branches/1.0/bin/varnishd/cache.h 2006-10-18 14:27:06 UTC (rev 1177)
@@ -371,6 +371,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);
+int http_IsBodyless(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);
int http_Read(struct http *hp, int fd, void *b, unsigned len);

Modified: branches/1.0/bin/varnishd/cache_http.c
===================================================================
--- branches/1.0/bin/varnishd/cache_http.c 2006-10-18 14:27:05 UTC (rev 1176)
+++ branches/1.0/bin/varnishd/cache_http.c 2006-10-18 14:27:06 UTC (rev 1177)
@@ -316,6 +316,21 @@
NULL /* XXX */, 10));
}

+/*---------------------------------------------------------------------
+ * All 1xx (informational), 204 (no content), and 304 (not modified)
+ * responses MUST NOT include a message-body.
+ */
+
+int
+http_IsBodyless(struct http *hp)
+{
+ int status;
+
+ status = http_GetStatus(hp);
+ return (status >= 100 && status < 200)
+ || status == 204 || status == 304;
+}
+
/*--------------------------------------------------------------------
* Dissect the headers of the HTTP protocol message.
* Detect conditionals (headers which start with '^[Ii][Ff]-')

Modified: branches/1.0/bin/varnishd/cache_pass.c
===================================================================
--- branches/1.0/bin/varnishd/cache_pass.c 2006-10-18 14:27:05 UTC (rev 1176)
+++ branches/1.0/bin/varnishd/cache_pass.c 2006-10-18 14:27:06 UTC (rev 1177)
@@ -201,6 +201,8 @@
cls = pass_straight(sp, vc->fd, vc->http, NULL);
else if (http_HdrIs(vc->http, H_Transfer_Encoding, "chunked"))
cls = pass_chunked(sp, vc->fd, vc->http);
+ else if (http_IsBodyless(vc->http))
+ cls = 0;
else {
cls = pass_straight(sp, vc->fd, vc->http, NULL);
}