diff --git a/Gemfile b/Gemfile index 8a2a449..41411dd 100644 --- a/Gemfile +++ b/Gemfile @@ -15,7 +15,7 @@ gem 'net-http-persistent', '~> 4.0', :require => false gem 'http', :require => false # adapter extensions -gem 'rack', '< 3' +gem 'rack' gem 'socksify' # coverage diff --git a/httpi.gemspec b/httpi.gemspec index 6abbba4..8930694 100644 --- a/httpi.gemspec +++ b/httpi.gemspec @@ -21,7 +21,7 @@ Gem::Specification.new do |s| s.license = 'MIT' - s.add_dependency 'rack', '< 3' + s.add_dependency 'rack', '>= 2.0', '< 3.1' s.add_dependency 'nkf' s.add_dependency 'base64' s.add_dependency 'mutex_m' @@ -30,7 +30,7 @@ Gem::Specification.new do |s| s.add_development_dependency 'rake', '~> 13.0' s.add_development_dependency 'rspec', '~> 3.5' s.add_development_dependency 'mocha', '~> 0.13' - s.add_development_dependency 'puma', '~> 5.0' + s.add_development_dependency 'puma', '~> 6.0' s.add_development_dependency 'webmock' s.metadata["rubygems_mfa_required"] = "true" diff --git a/lib/httpi/request.rb b/lib/httpi/request.rb index 8eebf9a..786e14c 100644 --- a/lib/httpi/request.rb +++ b/lib/httpi/request.rb @@ -64,12 +64,12 @@ def ssl? # Returns a Hash of HTTP headers. Defaults to return an empty Hash. def headers - @headers ||= Rack::Utils::HeaderHash.new + @headers ||= Rack::Headers.new end # Sets the Hash of HTTP headers. def headers=(headers) - @headers = Rack::Utils::HeaderHash.new(headers) + @headers = Rack::Headers.new.merge(headers) end # Adds a header information to accept gzipped content. diff --git a/lib/httpi/response.rb b/lib/httpi/response.rb index ca1162e..f9b7c4f 100644 --- a/lib/httpi/response.rb +++ b/lib/httpi/response.rb @@ -20,7 +20,7 @@ class Response # Initializer expects an HTTP response +code+, +headers+ and +body+. def initialize(code, headers, body) self.code = code.to_i - self.headers = Rack::Utils::HeaderHash.new(headers) + self.headers = Rack::Headers.new.merge(headers) self.raw_body = body end diff --git a/spec/httpi/request_spec.rb b/spec/httpi/request_spec.rb index 3c9c730..efd88ae 100644 --- a/spec/httpi/request_spec.rb +++ b/spec/httpi/request_spec.rb @@ -92,11 +92,11 @@ after { HTTPI.query_builder = :flat } it "lets you specify query parameter as Hash" do - expect(request.url.to_s).to eq("http://example.com?q[]=nested&q[]=query") + expect(request.url.to_s).to eq("http://example.com?q%5B%5D=nested&q%5B%5D=query") end it "getter return String for query parameter as Hash" do - expect(request.query).to eq("q[]=nested&q[]=query") + expect(request.query).to eq("q%5B%5D=nested&q%5B%5D=query") end end end @@ -149,7 +149,7 @@ describe "#headers" do it "lets you specify a Hash of HTTP request headers" do request.headers = { "Accept-Encoding" => "gzip" } - expect(request.headers).to eq({ "Accept-Encoding" => "gzip" }) + expect(request.headers).to eq Rack::Headers.new.merge({ "Accept-Encoding" => "gzip" }) end it "defaults to return an empty Hash" do @@ -235,7 +235,7 @@ def response_with_cookie(cookie) end it "request body using a Hash with Array" do request.body = {:foo => :bar, :baz => [:foo, :tst]} - expect(request.body.split("&")).to match_array(["foo=bar", "baz[]=foo", "baz[]=tst"]) + expect(request.body.split("&")).to match_array(["foo=bar", "baz%5B%5D=foo", "baz%5B%5D=tst"]) end end end diff --git a/spec/httpi/response_spec.rb b/spec/httpi/response_spec.rb index 2941575..d797bb3 100644 --- a/spec/httpi/response_spec.rb +++ b/spec/httpi/response_spec.rb @@ -88,7 +88,7 @@ describe "#headers" do it "returns the HTTP response headers" do - expect(response.headers).to eq({ "Content-Encoding" => "gzip" }) + expect(response.headers).to eq Rack::Headers.new.merge({ "Content-Encoding" => "gzip" }) end end @@ -116,7 +116,7 @@ describe "#headers" do it "returns the HTTP response headers" do - expect(response.headers).to eq({ "Content-Type" => "application/dime" }) + expect(response.headers).to eq Rack::Headers.new.merge({ "Content-Type" => "application/dime" }) end end diff --git a/spec/integration/support/server.rb b/spec/integration/support/server.rb index 368e27a..a7ae442 100644 --- a/spec/integration/support/server.rb +++ b/spec/integration/support/server.rb @@ -57,7 +57,7 @@ def stop private def events - Puma::Events.new($stdout, $stderr) + Puma::Events.new end def add_tcp_listener