Skip to content
This repository was archived by the owner on Feb 16, 2026. It is now read-only.
This repository was archived by the owner on Feb 16, 2026. It is now read-only.

on removing content-length for 0-length POST requests #4331

@gquintard

Description

@gquintard

Expected Behavior

POST requests should be exempt from content-length stripping, maybe.

Current Behavior

POST requests with an empty body are stripped from their content-length header

Possible Solution

No response

Steps to Reproduce (for bugs)

varnishtest "POST"

server s1 {
	rxreq
	txresp
	expect req.http.content-length == 0
} -start

varnish v1 -vcl+backend {

} -start

client c1 {
	txreq -method POST -hdr "content-length: 0"
	rxresp
} -run

server s1 -wait

Context

this is a follow-up on #4228, I'm not sure whether what I'm seeing here is an intended consequence of that fix.

Yvan on discord reported that lighttpd replies with a 411 if there's no content-length on a POST request, and that header is now read-only in VCL, so they can't fix it there.

Question is, who's at fault here? I would argue that Varnish is, but I'm not sure that's why I'm opening this ticket.

https://datatracker.ietf.org/doc/html/rfc7230#section-3.3.2 says:

A user agent SHOULD send a Content-Length in a request message when
no Transfer-Encoding is sent and the request method defines a meaning
for an enclosed payload body

POST qualifies here.

For example, a Content-Length header
field is normally sent in a POST request even when the value is 0
(indicating an empty payload body).

A user agent SHOULD NOT send a
Content-Length header field when the request message does not contain
a payload body and the method semantics do not anticipate such a
body.

A POST usually expects a body, so I think it's fair to send a content-length.

Varnish Cache version

varnishd (varnish-7.7.1 revision 2e8180f)

Operating system

arch, btw

Source of binary packages used (if any)

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions