summary refs log tree commit
diff options
context:
space:
mode:
authorSamuel Williams <samuel.williams@oriontransfer.co.nz>2022-08-02 03:24:02 +1200
committerGitHub <noreply@github.com>2022-08-01 08:24:02 -0700
commitb961d2b4810292163051bad4feb4ff1ca4ea50d1 (patch)
tree0d3ce16814eabe52fa6d8a264aaee299a2005c7c
parent291d5fb9b123bece91f429674cbaec98f14f8de7 (diff)
downloadrack-b961d2b4810292163051bad4feb4ff1ca4ea50d1.tar.gz
Remove requirement for `env['rack.version']`. (#1938)
-rw-r--r--CHANGELOG.md3
-rw-r--r--SPEC.rdoc4
-rw-r--r--lib/rack/handler/cgi.rb1
-rw-r--r--lib/rack/handler/webrick.rb1
-rwxr-xr-xlib/rack/lint.rb10
-rw-r--r--lib/rack/mock.rb1
-rwxr-xr-xtest/spec_lint.rb5
-rw-r--r--test/spec_mock.rb2
-rw-r--r--test/spec_webrick.rb5
9 files changed, 3 insertions, 29 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 6127ea29..98fd4ddc 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -18,7 +18,7 @@ All notable changes to this project will be documented in this file. For info on
 - Response body can now respond to `#call` (streaming body) instead of `#each` (enumerable body), for the equivalent of response hijacking in previous versions.
 - Middleware must no longer call `#each` on the body, but they can call `#to_ary` on the body if it responds to `#to_ary`.
 - `rack.input` is no longer required to be rewindable.
-- `rack.multithread/rack.multiprocess/rack.run_once` are no longer required environment keys.
+- `rack.multithread`/`rack.multiprocess`/`rack.run_once`/`rack.version` are no longer required environment keys.
 - `SERVER_PROTOCOL` is now a required key, matching the HTTP protocol used in the request.
 
 ### Removed
@@ -26,6 +26,7 @@ All notable changes to this project will be documented in this file. For info on
 - Remove `rack.multithread`/`rack.multiprocess`/`rack.run_once`. These variables generally come too late to be useful. ([#1720](https://github.com/rack/rack/pull/1720), [@ioquatix], [@jeremyevans]))
 - Remove deprecated Rack::Request::SCHEME_WHITELIST. ([@jeremyevans])
 - Remove internal cookie deletion using pattern matching, there are very few practical cases where it would be useful and browsers handle it correctly without us doing anything special. ([#1844](https://github.com/rack/rack/pull/1844), [@ioquatix])
+- Remove `rack.version` as it comes too late to be useful. ([#1938](https://gituhb.com/rack/rack/pull/1938), [@ioquatix])
 
 ### Added
 
diff --git a/SPEC.rdoc b/SPEC.rdoc
index 51c0bcdd..cc5f408e 100644
--- a/SPEC.rdoc
+++ b/SPEC.rdoc
@@ -73,9 +73,6 @@ below.
                            for specific behavior.
 In addition to this, the Rack environment must include these
 Rack-specific variables:
-<tt>rack.version</tt>:: The Array representing this version of Rack
-                        See Rack::VERSION, that corresponds to
-                        the version of this SPEC.
 <tt>rack.url_scheme</tt>:: +http+ or +https+, depending on the
                            request URL.
 <tt>rack.input</tt>:: See below, the input stream.
@@ -128,7 +125,6 @@ The CGI keys (named without a period) must have String values.
 If the string values for CGI keys contain non-ASCII characters,
 they should use ASCII-8BIT encoding.
 There are the following restrictions:
-* <tt>rack.version</tt> must be an array of Integers.
 * <tt>rack.url_scheme</tt> must either be +http+ or +https+.
 * There must be a valid input stream in <tt>rack.input</tt>.
 * There must be a valid error stream in <tt>rack.errors</tt>.
diff --git a/lib/rack/handler/cgi.rb b/lib/rack/handler/cgi.rb
index 2fe32689..eecbaf03 100644
--- a/lib/rack/handler/cgi.rb
+++ b/lib/rack/handler/cgi.rb
@@ -15,7 +15,6 @@ module Rack
         env[SCRIPT_NAME] = ""  if env[SCRIPT_NAME] == "/"
 
         env.update(
-          RACK_VERSION      => Rack::VERSION,
           RACK_INPUT        => $stdin,
           RACK_ERRORS       => $stderr,
           RACK_URL_SCHEME   => ["yes", "on", "1"].include?(ENV[HTTPS]) ? "https" : "http"
diff --git a/lib/rack/handler/webrick.rb b/lib/rack/handler/webrick.rb
index a82dd585..5cd0eca4 100644
--- a/lib/rack/handler/webrick.rb
+++ b/lib/rack/handler/webrick.rb
@@ -76,7 +76,6 @@ module Rack
         rack_input.set_encoding(Encoding::BINARY)
 
         env.update(
-          RACK_VERSION      => Rack::VERSION,
           RACK_INPUT        => rack_input,
           RACK_ERRORS       => $stderr,
           RACK_URL_SCHEME   => ["yes", "on", "1"].include?(env[HTTPS]) ? "https" : "http",
diff --git a/lib/rack/lint.rb b/lib/rack/lint.rb
index c92e2268..da409070 100755
--- a/lib/rack/lint.rb
+++ b/lib/rack/lint.rb
@@ -162,10 +162,6 @@ module Rack
         ## In addition to this, the Rack environment must include these
         ## Rack-specific variables:
 
-        ## <tt>rack.version</tt>:: The Array representing this version of Rack
-        ##                         See Rack::VERSION, that corresponds to
-        ##                         the version of this SPEC.
-
         ## <tt>rack.url_scheme</tt>:: +http+ or +https+, depending on the
         ##                            request URL.
 
@@ -274,7 +270,7 @@ module Rack
         ##
 
         %w[REQUEST_METHOD SERVER_NAME QUERY_STRING SERVER_PROTOCOL
-           rack.version rack.input rack.errors].each { |header|
+           rack.input rack.errors].each { |header|
           raise LintError, "env missing required key #{header}" unless env.include? header
         }
 
@@ -330,10 +326,6 @@ module Rack
 
         ## There are the following restrictions:
 
-        ## * <tt>rack.version</tt> must be an array of Integers.
-        unless env[RACK_VERSION].kind_of? Array
-          raise LintError, "rack.version must be an Array, was #{env[RACK_VERSION].class}"
-        end
         ## * <tt>rack.url_scheme</tt> must either be +http+ or +https+.
         unless %w[http https].include?(env[RACK_URL_SCHEME])
           raise LintError, "rack.url_scheme unknown: #{env[RACK_URL_SCHEME].inspect}"
diff --git a/lib/rack/mock.rb b/lib/rack/mock.rb
index c06e5390..c048e302 100644
--- a/lib/rack/mock.rb
+++ b/lib/rack/mock.rb
@@ -46,7 +46,6 @@ module Rack
     end
 
     DEFAULT_ENV = {
-      RACK_VERSION      => Rack::VERSION,
       RACK_INPUT        => StringIO.new,
       RACK_ERRORS       => StringIO.new,
     }.freeze
diff --git a/test/spec_lint.rb b/test/spec_lint.rb
index 2242b1f9..785509c7 100755
--- a/test/spec_lint.rb
+++ b/test/spec_lint.rb
@@ -85,11 +85,6 @@ describe Rack::Lint do
       message.must_match(/non-string value/)
 
     lambda {
-      Rack::Lint.new(nil).call(env("rack.version" => "0.2"))
-    }.must_raise(Rack::Lint::LintError).
-      message.must_match(/must be an Array/)
-
-    lambda {
       Rack::Lint.new(nil).call(env("rack.url_scheme" => "gopher"))
     }.must_raise(Rack::Lint::LintError).
       message.must_match(/url_scheme unknown/)
diff --git a/test/spec_mock.rb b/test/spec_mock.rb
index 4bc57b18..1eb4fc43 100644
--- a/test/spec_mock.rb
+++ b/test/spec_mock.rb
@@ -46,7 +46,6 @@ describe Rack::MockRequest do
   it "be able to only return the environment" do
     env = Rack::MockRequest.env_for("")
     env.must_be_kind_of Hash
-    env.must_include "rack.version"
   end
 
   it "should handle a non-GET request with both :input and :params" do
@@ -61,7 +60,6 @@ describe Rack::MockRequest do
     env["QUERY_STRING"].must_equal "location[]=1&location[]=2&age_group[]=2"
     env["PATH_INFO"].must_equal "/parse"
     env.must_be_kind_of Hash
-    env.must_include "rack.version"
   end
 
   it "provide sensible defaults" do
diff --git a/test/spec_webrick.rb b/test/spec_webrick.rb
index 322672ac..302d7cb2 100644
--- a/test/spec_webrick.rb
+++ b/test/spec_webrick.rb
@@ -55,11 +55,6 @@ describe Rack::Handler::WEBrick do
     response["SERVER_NAME"].must_equal "localhost"
   end
 
-  it "have rack headers" do
-    GET("/test")
-    response["rack.version"].must_equal [1, 3]
-  end
-
   it "have CGI headers on GET" do
     GET("/test")
     response["REQUEST_METHOD"].must_equal "GET"