You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This commit was created on GitHub.com and signed with GitHub’s verified signature.
Behavior changes: read before upgrading
A Content-Length set through Nginx::Headers_out is no longer sent as a response header line
Before: Nginx::Headers_out#[]= with the name Content-Length added a Content-Length response header line next to the one that nginx writes from the length of the response body, so a response could carry two Content-Length lines with different values.
Now: a Content-Length that a script sets through Nginx::Headers_out is not sent; nginx sends its own Content-Length for the response, as it does when the script sets none.
Why it changed:
The defect: the second Content-Length line that a script's value added next to the one nginx writes. A response with two differing Content-Length lines has no single body length. On a response that nginx sends with Transfer-Encoding: chunked, the script's line was added next to the Transfer-Encoding, which leaves no single body length either; GHSA-2cf7-qh69-j29q has the details.
Why the old behavior could not be kept: the line a script set could not be made to agree with the body in every case, so the fix sends only the length that nginx frames the body by.
What the documentation promised: docs/class_and_method/ on the 2.x line did not describe setting Content-Length through Nginx::Headers_out.
Affected: a configuration whose Ruby code sets Content-Length through Nginx::Headers_out in a content handler, a phase handler or an output header filter. Reading Content-Length with Nginx::Headers_out#[] and removing it with #delete are unchanged.
What to do: remove the Nginx::Headers_out#[]= of Content-Length; nginx sends the length of the response. A response of a fixed length is sent by writing that many bytes with Nginx.rputs, whose total nginx sends as the Content-Length.