From c72181dcb7d32e37dfd7a26084aeb6738cfa58a3 Mon Sep 17 00:00:00 2001 From: Paul Jolly Date: Wed, 29 Jan 2014 17:43:39 +0000 Subject: [PATCH] Fix #559: Rack 1.6.0 properly parses requests larger than 128KB. --- CHANGELOG.md | 1 + UPGRADING.md | 10 ++++++++++ spec/grape/integration/rack_spec.rb | 26 ++++++++++++++++++++++++++ 3 files changed, 37 insertions(+) create mode 100644 spec/grape/integration/rack_spec.rb diff --git a/CHANGELOG.md b/CHANGELOG.md index 963d43eeb4..102877aa08 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ Next Release ============ * [#871](https://github.com/intridea/grape/pull/871): Fixed Grape::Middleware::Base#response - [@galathius](https://github.com/galathius). +* [#559](https://github.com/intridea/grape/issues/559): Support Rack 1.6.0 to parse requests larger than 128KB - [@myitcv](https://github.com/myitcv). * Your contribution here. 0.10.1 (12/28/2014) diff --git a/UPGRADING.md b/UPGRADING.md index d162ed0b38..d849e5eee1 100644 --- a/UPGRADING.md +++ b/UPGRADING.md @@ -1,6 +1,16 @@ Upgrading Grape =============== +### Upgrading to >= 0.10.2 + +Grape now supports, but doesn't require Rack 1.6.0. If you encounter an issue with parsing requests larger than 128KB, explictly require Rack 1.6.0 in your Gemfile. + +```ruby +gem 'rack', '~> 1.6.0' +``` + +See [#559](https://github.com/intridea/grape/issues/559) for more information. + ### Upgrading to >= 0.10.1 #### Changes to `declared(params, include_missing: false)` diff --git a/spec/grape/integration/rack_spec.rb b/spec/grape/integration/rack_spec.rb new file mode 100644 index 0000000000..0f04e264d2 --- /dev/null +++ b/spec/grape/integration/rack_spec.rb @@ -0,0 +1,26 @@ +require 'spec_helper' + +describe Rack do + it 'correctly populates params from a Tempfile' do + input = Tempfile.new 'rubbish' + begin + app = Class.new(Grape::API) do + format :json + post do + { params_keys: params.keys } + end + end + input.write({ test: '123' * 10_000 }.to_json) + input.rewind + options = { + input: input, + method: 'POST', + 'CONTENT_TYPE' => 'application/json' + } + env = Rack::MockRequest.env_for('/', options) + expect(JSON.parse(app.call(env)[2].body.first)['params_keys']).to match_array(%w(route_info test)) + ensure + input.unlink + end + end +end