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
The test doesn't handle when content type isn't supplied at all, it's given as a blank string:
it 'parses data in default format' do
subject.post '/data' do
{ x: params[:x] }
end
post '/data', '{"x":42}', 'CONTENT_TYPE' => ''
expect(last_response.status).to eq(201)
expect(last_response.body).to eq('{"x":42}')
end
When I remove that content type and post without it, it breaks without even making it to #read_rack_input and test fails.
These are both false in #read_body_input so it returns here:
(!request.form_data? || !request.media_type)
content_type/media_type default to "application/x-www-form-urlencoded" when content-type isn't supplied. And since request.media_type is "application/x-www-form-urlencoded" instead of nil, it wouldn't use the default_format here either even if we made it to this point:
from grape/lib/grape/middleware/formatter.rb #read_rack_input
fmt = mime_types[request.media_type] if request.media_type
fmt ||= options[:default_format]
The text was updated successfully, but these errors were encountered:
Follow-up on old issue #407
format and default_format are set to :json yet when content-type is not supplied it doesn't parse correctly:
results in:
The test doesn't handle when content type isn't supplied at all, it's given as a blank string:
When I remove that content type and post without it, it breaks without even making it to #read_rack_input and test fails.
These are both false in #read_body_input so it returns here:
content_type/media_type default to "application/x-www-form-urlencoded" when content-type isn't supplied. And since request.media_type is "application/x-www-form-urlencoded" instead of nil, it wouldn't use the default_format here either even if we made it to this point:
from
grape/lib/grape/middleware/formatter.rb
#read_rack_inputThe text was updated successfully, but these errors were encountered: