diff options
author | Samuel Williams <samuel.williams@oriontransfer.co.nz> | 2019-12-14 10:11:15 +1300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-12-14 10:11:15 +1300 |
commit | 49ed3267e4181b47fe53431be4805968eed81e3d (patch) | |
tree | 3b5b51d3992ddde51decd1c441aa47396c033030 | |
parent | d6668ee1f6f8d91c1ee2aac09ccfcd5e117216bd (diff) | |
parent | 211e87946b6b1d9a1829adf991224862449e9f48 (diff) | |
download | rack-49ed3267e4181b47fe53431be4805968eed81e3d.tar.gz |
Merge pull request #1426 from osamtimizer/fix/eliminate-warnings-on-test
Eliminate warnings for Ruby2.7.0-preview3
-rw-r--r-- | SPEC | 2 | ||||
-rw-r--r-- | lib/rack/lint.rb | 10 | ||||
-rw-r--r-- | test/spec_server.rb | 6 |
3 files changed, 12 insertions, 6 deletions
@@ -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 diff --git a/test/spec_server.rb b/test/spec_server.rb index b09caf03..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 = 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, $$) |