Fix content-type header with send_stream
#46327
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The Rack specification states that header values must be a
String
instance (or array thereof).When setting up the content-type header based on the file extension,
send_stream
assigns the wholeMime::Type
object, instead of itsString
representation.
This change ensures that all three ways of setting the content-type header (implicit via extension,
implicit via a symbol, and explicit via a string)
all result in a
String
instance being assigned as the header's value.Motivation / Background
This Pull Request has been created because other libraries (in this case specifically https://github.com/DFE-Digital/dfe-analytics and its use of BigQuery) assume that header values will be strings per the rack spec.
Detail
This Pull Request changes the behaviour of
send_stream
when it is inferring a content-type from the file extension, so that it assigns aString
instance as the header value rather than aMime::Type
instance.Checklist
Before submitting the PR make sure the following are checked:
[Fix #issue-number]