Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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

@p-himik

Description

@p-himik

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions