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

Fix header casing compatibility with Rails 7 #790

Merged
merged 1 commit into from
Sep 5, 2023

Commits on Aug 10, 2023

  1. Fix header casing compatibility with Rails 7

    To support Rack 3, response headers in `Sprockets::Server` were all
    downcased. However, this has led to issues with Rack 2 applications (ex.
    Rails 7) since they still expect mixed case (ex. `Content-Type`)
    headers.
    
    To ensure compatibility with both Rack 2 and Rack 3 applications, this
    commit makes the casing of the headers conditional on the Rack version.
    Rack itself provides constants to do this easily for most of the headers
    used (`Content-Type`, `Content-Length`, `Cache-Control`, and `ETag`) and
    the rest are added as constants under `Rack::Server`.
    
    As an alternative to this, the responses could instead be wrapped using
    `Rack::Headers` (and `Rack::Utils::HeaderHash` in Rack 2), but making
    the header casing conditional seems better to me because it is
    relatively easier to implement and there will be less churn if/when Rack
    2 support is eventually removed.
    skipkayhil committed Aug 10, 2023
    Configuration menu
    Copy the full SHA
    5d795a7 View commit details
    Browse the repository at this point in the history