Commit 05249f92 authored by Guillaume Quintard's avatar Guillaume Quintard Committed by guillaume quintard

Don't mess with C-L when responding to HEAD

parent cc51ba94
......@@ -341,7 +341,7 @@ cnt_transmit(struct worker *wrk, struct req *req)
struct boc *boc;
const char *r;
uint16_t status;
int err, sendbody;
int err, sendbody, head;
intmax_t clval;
CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
......@@ -363,7 +363,8 @@ cnt_transmit(struct worker *wrk, struct req *req)
/* RFC 7230, 3.3.3 */
status = http_GetStatus(req->resp);
if (!strcmp(req->http0->hd[HTTP_HDR_METHOD].b, "HEAD")) {
head = !strcmp(req->http0->hd[HTTP_HDR_METHOD].b, "HEAD");
if (head) {
if (req->objcore->flags & OC_F_PASS)
sendbody = -1;
else
......@@ -395,8 +396,8 @@ cnt_transmit(struct worker *wrk, struct req *req)
}
}
if (sendbody < 0) {
/* Don't touch pass+HEAD C-L */
if (sendbody < 0 || head) {
/* Don't touch HEAD C-L */
sendbody = 0;
} else if (clval >= 0 && clval == req->resp_len) {
/* Reuse C-L header */
......
varnishtest "Test that C-L on HEAD request aren't nuked"
server s1 {
rxreq
txresp -nolen -hdr "content-length: 17"
expect req.method == "HEAD"
} -start
varnish v1 -vcl+backend {
sub vcl_backend_fetch {
set bereq.method = "HEAD";
}
} -start
client c1 {
txreq -req HEAD -hdr "connection: close"
rxresphdrs
expect resp.http.content-length == 17
expect_close
} -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