From b961d2b4810292163051bad4feb4ff1ca4ea50d1 Mon Sep 17 00:00:00 2001 From: Samuel Williams Date: Tue, 2 Aug 2022 03:24:02 +1200 Subject: Remove requirement for `env['rack.version']`. (#1938) --- CHANGELOG.md | 3 ++- SPEC.rdoc | 4 ---- lib/rack/handler/cgi.rb | 1 - lib/rack/handler/webrick.rb | 1 - lib/rack/lint.rb | 10 +--------- lib/rack/mock.rb | 1 - test/spec_lint.rb | 5 ----- test/spec_mock.rb | 2 -- test/spec_webrick.rb | 5 ----- 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: -rack.version:: The Array representing this version of Rack - See Rack::VERSION, that corresponds to - the version of this SPEC. rack.url_scheme:: +http+ or +https+, depending on the request URL. rack.input:: 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: -* rack.version must be an array of Integers. * rack.url_scheme must either be +http+ or +https+. * There must be a valid input stream in rack.input. * There must be a valid error stream in rack.errors. 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: - ## rack.version:: The Array representing this version of Rack - ## See Rack::VERSION, that corresponds to - ## the version of this SPEC. - ## rack.url_scheme:: +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: - ## * rack.version 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 ## * rack.url_scheme 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 @@ -84,11 +84,6 @@ describe Rack::Lint do }.must_raise(Rack::Lint::LintError). 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). 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" -- cgit v1.2.3-24-ge0c7