[master] 81b1736 Be more precise about when we take EOF bodies on requests.

Poul-Henning Kamp phk at FreeBSD.org
Tue Sep 9 10:33:37 CEST 2014


commit 81b17367de895fc888a94aa6797c7e28b69c2f28
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Tue Sep 9 08:33:15 2014 +0000

    Be more precise about when we take EOF bodies on requests.

diff --git a/bin/varnishd/cache/cache_http1_fsm.c b/bin/varnishd/cache/cache_http1_fsm.c
index 8203987..ede17bb 100644
--- a/bin/varnishd/cache/cache_http1_fsm.c
+++ b/bin/varnishd/cache/cache_http1_fsm.c
@@ -309,8 +309,7 @@ http1_dissect(struct worker *wrk, struct req *req)
 	} else if (req->htc->body_status == BS_NONE) {
 		req->req_body_status = REQ_BODY_NONE;
 	} else if (req->htc->body_status == BS_EOF) {
-		/* XXX: We don't support EOF bodies in requests */
-		req->req_body_status = REQ_BODY_NONE;
+		req->req_body_status = REQ_BODY_PRESENT;
 	} else {
 		WRONG("Unknown req.body_length situation");
 	}
diff --git a/bin/varnishd/cache/cache_http1_proto.c b/bin/varnishd/cache/cache_http1_proto.c
index 97b184e..79288c6 100644
--- a/bin/varnishd/cache/cache_http1_proto.c
+++ b/bin/varnishd/cache/cache_http1_proto.c
@@ -443,6 +443,7 @@ uint16_t
 HTTP1_DissectRequest(struct http_conn *htc, struct http *hp)
 {
 	uint16_t retval;
+	const char *p;
 	char *b, *e;
 
 	CHECK_OBJ_NOTNULL(htc, HTTP_CONN_MAGIC);
@@ -472,10 +473,21 @@ HTTP1_DissectRequest(struct http_conn *htc, struct http *hp)
 	}
 
 	htc->body_status = http1_body_status(hp, htc);
-
 	if (htc->body_status == BS_ERROR)
 		return (400);
 
+	p = http_GetMethod(hp);
+	AN(p);
+
+	/* We handle EOF bodies only for PUT and POST */
+	if (htc->body_status == BS_EOF &&
+	    strcasecmp(p, "put") && strcasecmp(p, "post"))
+		htc->body_status = BS_NONE;
+
+	/* HEAD with a body is a hard error */
+	if (htc->body_status != BS_NONE && !strcasecmp(p, "head"))
+		return (400);
+
 	return (retval);
 }
 



More information about the varnish-commit mailing list