From 7481f31819ce24051eee0874d796eccda46157cb Mon Sep 17 00:00:00 2001 From: David Roetzel Date: Mon, 2 Dec 2024 23:09:42 +0100 Subject: [PATCH] Add `rack` 2 backwards compat (#4) `rack` version 2 two requires a `rack.input`, other than that it is 100% compatible with version 3 when it comes to the methods that linzer uses. Relaxing the version requirement this way allows people to adopt linzer that are stuck on `rack` 2 for whatever reason. --- Gemfile.lock | 4 ++-- lib/linzer/request.rb | 3 ++- linzer.gemspec | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index daaf0e2..374c1f5 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -4,7 +4,7 @@ PATH linzer (0.6.0) ed25519 (~> 1.3, >= 1.3.0) openssl (~> 3.0, >= 3.0.0) - rack (~> 3.0) + rack (>= 2.2, < 4.0) starry (~> 0.2) uri (~> 0.12, >= 0.12.0) @@ -25,7 +25,7 @@ GEM ast (~> 2.4.1) racc racc (1.7.3) - rack (3.0.11) + rack (3.1.8) rainbow (3.1.1) rake (13.2.1) regexp_parser (2.9.0) diff --git a/lib/linzer/request.rb b/lib/linzer/request.rb index 17698dc..6b63f82 100644 --- a/lib/linzer/request.rb +++ b/lib/linzer/request.rb @@ -11,7 +11,8 @@ def build(verb, uri = "/", params = {}, headers = {}) request_method = Rack.const_get(verb.upcase) args = { "REQUEST_METHOD" => request_method, - "PATH_INFO" => uri.to_str + "PATH_INFO" => uri.to_str, + "rack.input" => StringIO.new } Rack::Request.new(build_rack_env(headers).merge(args)) diff --git a/linzer.gemspec b/linzer.gemspec index 2608b50..f3a4386 100644 --- a/linzer.gemspec +++ b/linzer.gemspec @@ -32,6 +32,6 @@ Gem::Specification.new do |spec| spec.add_runtime_dependency "openssl", "~> 3.0", ">= 3.0.0" spec.add_runtime_dependency "ed25519", "~> 1.3", ">= 1.3.0" spec.add_runtime_dependency "starry", "~> 0.2" - spec.add_runtime_dependency "rack", "~> 3.0" + spec.add_runtime_dependency "rack", ">= 2.2", "< 4.0" spec.add_runtime_dependency "uri", "~> 0.12", ">= 0.12.0" end