Commit a5bf869f authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Don't send Content-Length on 304 responses.

It seems that browser writers also have trouble figuring out that
twisted logic in HTTP/1.1.

Fixes:	#1404
Spotted by:	Scoof
parent 3d50d453
......@@ -207,6 +207,10 @@ V1D_Deliver(struct req *req)
/* In ESI mode, we can't know the aggregate length */
req->res_mode &= ~RES_LEN;
req->res_mode |= RES_ESI;
} else if (req->resp->status == 304) {
req->res_mode &= ~RES_LEN;
http_Unset(req->resp, H_Content_Length);
req->wantbody = 0;
} else if (req->obj->objcore->busyobj == NULL) {
/* XXX: Not happy with this convoluted test */
req->res_mode |= RES_LEN;
......@@ -284,9 +288,6 @@ V1D_Deliver(struct req *req)
if (!(req->res_mode & RES_ESI_CHILD))
req->acct_req.hdrbytes += HTTP1_Write(req->wrk, req->resp, 1);
if (!req->wantbody)
req->res_mode &= ~RES_CHUNKED;
if (req->res_mode & RES_CHUNKED)
WRW_Chunked(req->wrk);
......
......@@ -146,12 +146,10 @@ cnt_deliver(struct worker *wrk, struct req *req)
assert(wrk->handling == VCL_RET_DELIVER);
if (!(req->obj->objcore->flags & OC_F_PASS)
&& req->esi_level == 0
&& req->obj->response == 200
&& req->http->conds && RFC2616_Do_Cond(req)) {
req->wantbody = 0;
&& req->http->conds && RFC2616_Do_Cond(req))
http_SetResp(req->resp, "HTTP/1.1", 304, "Not Modified");
// http_Unset(req->resp, H_Content_Length);
}
V1D_Deliver(req);
......
varnishtest "Test that 304 does not send Content-Length"
server s1 {
rxreq
txresp -hdr "ETag: foo" -body "11111\n"
} -start
varnish v1 -vcl+backend {
sub vcl_backend_response {
set beresp.do_stream = true;
}
} -start
client c1 {
txreq -hdr "If-None-Match: foo"
rxresp -no_obj
expect resp.status == 304
expect resp.http.Content-Length == <undef>
} -run
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment