-
Notifications
You must be signed in to change notification settings - Fork 791
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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.
- Loading branch information
1 parent
6554b6d
commit 5d795a7
Showing
2 changed files
with
30 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters