Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

content-length is incorrectly set to 0 when responding with HTTP 304 to GET requests #326

Open
p-himik opened this issue Jan 24, 2022 · 0 comments

Comments

@p-himik
Copy link

p-himik commented Jan 24, 2022

The culprit:

(when (not= (:method ctx) :head)
(when-let [cl (body/content-length body)]
{"content-length" (str cl)}))

Why it's incorrect: https://datatracker.ietf.org/doc/html/rfc7230#section-3.3.2

A server MAY send a Content-Length header field in a 304 (Not
Modified) response to a conditional GET request (Section 4.1 of
[RFC7232]); a server MUST NOT send Content-Length in such a response
unless its field-value equals the decimal number of octets that would
have been sent in the payload body of a 200 (OK) response to the same
request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant