mirror of
https://github.com/sinatra/sinatra
synced 2023-03-27 23:18:01 -04:00
Handle EOFError raised by Rack
This commit is contained in:
parent
e69b6b9dee
commit
df65a73f77
2 changed files with 11 additions and 0 deletions
|
@ -78,6 +78,8 @@ module Sinatra
|
|||
super
|
||||
rescue Rack::Utils::ParameterTypeError, Rack::Utils::InvalidParameterError => e
|
||||
raise BadRequest, "Invalid query parameters: #{Rack::Utils.escape_html(e.message)}"
|
||||
rescue EOFError => e
|
||||
raise BadRequest, "Invalid multipart/form-data: #{Rack::Utils.escape_html(e.message)}"
|
||||
end
|
||||
|
||||
class AcceptEntry
|
||||
|
|
|
@ -17,6 +17,15 @@ class RequestTest < Minitest::Test
|
|||
assert_equal 'bar', request.params['foo']
|
||||
end
|
||||
|
||||
it 'raises Sinatra::BadRequest when multipart/form-data request has no content' do
|
||||
request = Sinatra::Request.new(
|
||||
'REQUEST_METHOD' => 'POST',
|
||||
'CONTENT_TYPE' => 'multipart/form-data; boundary=dummy',
|
||||
'rack.input' => StringIO.new('')
|
||||
)
|
||||
assert_raises(Sinatra::BadRequest) { request.params }
|
||||
end
|
||||
|
||||
it 'is secure when the url scheme is https' do
|
||||
request = Sinatra::Request.new('rack.url_scheme' => 'https')
|
||||
assert request.secure?
|
||||
|
|
Loading…
Reference in a new issue