mjackson / mjackson/rack-accept
Accessing request params via Rack::Accept::Request
Nobody has claimed this yet.
- Dominant language
- Ruby
- Stars
- 48
- Forks
- 15
- PR merge metrics
- No merged PRs in 30d
Description
Rack::Accept::Request overrides media_type but changes the return value. Instead of returning the request's content-type -less charset, like its parent, it returns an accept header (as an instance of MediaType). This prevents one from retrieving POST params:
[Rack::Accept::Request, Rack::Request].each do |klass|
env = {
"rack.input" => StringIO.new("a=b+c"),
"CONTENT_TYPE" => "multipart/form-data",
"REQUEST_METHOD" => "POST"
}
r = klass.new(env)
puts "#{klass.name}#POST: #{r.POST}"
puts "#{klass.name}#media_type: #{r.media_type}"
puts "*" * 10
end
Prints:
Rack::Accept::Request#POST: {}
Rack::Accept::Request#media_type: Accept:
**********
Rack::Request#POST: {"a"=>"b c"}
Rack::Request#media_type: multipart/form-data
**********
Maybe it's better to call the method accept
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at Rack::Accept::Request#media_type and compare it with Rack::Request#media_type, using the reproduction in the issue to confirm how the override affects POST parsing. Add regression coverage for request parameters and verify that media type and Accept handling produce the intended values.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ruby
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100