From 72d8f464ec1dd36a8731ace0bf102d6f0523f995 Mon Sep 17 00:00:00 2001 From: osamtimizer Date: Sat, 14 Dec 2019 00:47:39 +0900 Subject: calling URI.open via Kernel#open is deprecated --- test/spec_server.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/spec_server.rb b/test/spec_server.rb index b09caf03..99142572 100644 --- a/test/spec_server.rb +++ b/test/spec_server.rb @@ -132,7 +132,7 @@ describe Rack::Server do ) t = Thread.new { server.start { |s| Thread.current[:server] = s } } t.join(0.01) until t[:server] && t[:server].status != :Stop - body = open("http://127.0.0.1:#{server.options[:Port]}/") { |f| f.read } + body = URI.open("http://127.0.0.1:#{server.options[:Port]}/") { |f| f.read } body.must_equal 'success' Process.kill(:INT, $$) -- cgit v1.2.3-24-ge0c7 From 3d5491e3b9600b9a287061633b2216e0b10e8aac Mon Sep 17 00:00:00 2001 From: osamtimizer Date: Sat, 14 Dec 2019 01:10:11 +0900 Subject: eliminate warning for testing of passing invalid header --- SPEC | 2 +- lib/rack/lint.rb | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/SPEC b/SPEC index 3352b843..59ec9d72 100644 --- a/SPEC +++ b/SPEC @@ -225,9 +225,9 @@ This is an HTTP status. When parsed as integer (+to_i+), it must be greater than or equal to 100. === The Headers The header must respond to +each+, and yield values of key and value. +The header keys must be Strings. Special headers starting "rack." are for communicating with the server, and must not be sent back to the client. -The header keys must be Strings. The header must not contain a +Status+ key. The header must conform to RFC7230 token specification, i.e. cannot contain non-printable ASCII, DQUOTE or "(),/:;<=>?@[\]{}". diff --git a/lib/rack/lint.rb b/lib/rack/lint.rb index 17b188f4..98ba9b44 100644 --- a/lib/rack/lint.rb +++ b/lib/rack/lint.rb @@ -627,15 +627,17 @@ module Rack assert("headers object should respond to #each, but doesn't (got #{header.class} as headers)") { header.respond_to? :each } - header.each { |key, value| - ## Special headers starting "rack." are for communicating with the - ## server, and must not be sent back to the client. - next if key =~ /^rack\..+$/ + header.each { |key, value| ## The header keys must be Strings. assert("header key must be a string, was #{key.class}") { key.kind_of? String } + + ## Special headers starting "rack." are for communicating with the + ## server, and must not be sent back to the client. + next if key =~ /^rack\..+$/ + ## The header must not contain a +Status+ key. assert("header must not contain Status") { key.downcase != "status" } ## The header must conform to RFC7230 token specification, i.e. cannot -- cgit v1.2.3-24-ge0c7 From 211e87946b6b1d9a1829adf991224862449e9f48 Mon Sep 17 00:00:00 2001 From: osamtimizer Date: Sat, 14 Dec 2019 02:13:10 +0900 Subject: in ruby2.4.0, URI doesn't respond to :open --- test/spec_server.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/test/spec_server.rb b/test/spec_server.rb index 99142572..8aecc554 100644 --- a/test/spec_server.rb +++ b/test/spec_server.rb @@ -132,7 +132,11 @@ describe Rack::Server do ) t = Thread.new { server.start { |s| Thread.current[:server] = s } } t.join(0.01) until t[:server] && t[:server].status != :Stop - body = URI.open("http://127.0.0.1:#{server.options[:Port]}/") { |f| f.read } + body = if URI.respond_to?(:open) + URI.open("http://127.0.0.1:#{server.options[:Port]}/") { |f| f.read } + else + open("http://127.0.0.1:#{server.options[:Port]}/") { |f| f.read } + end body.must_equal 'success' Process.kill(:INT, $$) -- cgit v1.2.3-24-ge0c7