From 5e883dd08a0b596f9143c2d94e33054faed2b7e9 Mon Sep 17 00:00:00 2001 From: Troels Thomsen <19824+tt@users.noreply.github.com> Date: Mon, 17 Jun 2024 16:24:22 +0200 Subject: [PATCH] Ensure body is rewound (#425) * Ensure body is rewound * Remove version constraint * Declare Rack compatibility --- committee.gemspec | 4 ++-- lib/committee/request_unpacker.rb | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/committee.gemspec b/committee.gemspec index 1e39a078..ebdaaad2 100644 --- a/committee.gemspec +++ b/committee.gemspec @@ -22,11 +22,11 @@ Gem::Specification.new do |s| s.add_dependency "json_schema", "~> 0.14", ">= 0.14.3" - s.add_dependency "rack", ">= 1.5" + s.add_dependency "rack", ">= 1.5", "< 3.1" s.add_dependency "openapi_parser", "~> 2.0" s.add_development_dependency "minitest", "~> 5.3" - s.add_development_dependency "rack-test", "~> 0.8" + s.add_development_dependency "rack-test" s.add_development_dependency "rake", "~> 13.1" s.add_development_dependency "pry" s.add_development_dependency "pry-byebug" diff --git a/lib/committee/request_unpacker.rb b/lib/committee/request_unpacker.rb index abddd264..c6293db1 100644 --- a/lib/committee/request_unpacker.rb +++ b/lib/committee/request_unpacker.rb @@ -46,7 +46,11 @@ def unpack_request_params(request) if @allow_form_params && %w[application/x-www-form-urlencoded multipart/form-data].include?(request.media_type) # Actually, POST means anything in the request body, could be from # PUT or PATCH too. Silly Rack. - return [request.POST, true] if request.POST + begin + return [request.POST, true] if request.POST + ensure + request.body.rewind + end end [{}, false]