diff options
-rw-r--r-- | README.rdoc | 2 | ||||
-rw-r--r-- | lib/rack/handler/scgi.rb | 3 | ||||
-rw-r--r-- | lib/rack/lock.rb | 15 | ||||
-rw-r--r-- | rack.gemspec | 4 | ||||
-rw-r--r-- | test/spec_lock.rb | 12 |
5 files changed, 28 insertions, 8 deletions
diff --git a/README.rdoc b/README.rdoc index d87bc82e..c97d4968 100644 --- a/README.rdoc +++ b/README.rdoc @@ -296,7 +296,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. == Links -Rack:: <http://rack.github.io/> +Rack:: <https://rack.github.io/> Official Rack repositories:: <https://github.com/rack> Rack Bug Tracking:: <https://github.com/rack/rack/issues> rack-devel mailing list:: <https://groups.google.com/group/rack-devel> diff --git a/lib/rack/handler/scgi.rb b/lib/rack/handler/scgi.rb index e056a01d..beda9c3e 100644 --- a/lib/rack/handler/scgi.rb +++ b/lib/rack/handler/scgi.rb @@ -41,7 +41,8 @@ module Rack env[QUERY_STRING] ||= "" env[SCRIPT_NAME] = "" - rack_input = StringIO.new(input_body, encoding: Encoding::BINARY) + rack_input = StringIO.new(input_body) + rack_input.set_encoding(Encoding::BINARY) env.update( RACK_VERSION => Rack::VERSION, diff --git a/lib/rack/lock.rb b/lib/rack/lock.rb index 923dca59..b5a41e8e 100644 --- a/lib/rack/lock.rb +++ b/lib/rack/lock.rb @@ -11,12 +11,21 @@ module Rack def call(env) @mutex.lock + @env = env + @old_rack_multithread = env[RACK_MULTITHREAD] begin - response = @app.call(env.merge(RACK_MULTITHREAD => false)) - returned = response << BodyProxy.new(response.pop) { @mutex.unlock } + response = @app.call(env.merge!(RACK_MULTITHREAD => false)) + returned = response << BodyProxy.new(response.pop) { unlock } ensure - @mutex.unlock unless returned + unlock unless returned end end + + private + + def unlock + @mutex.unlock + @env[RACK_MULTITHREAD] = @old_rack_multithread + end end end diff --git a/rack.gemspec b/rack.gemspec index d48b5f3a..ec2b79f6 100644 --- a/rack.gemspec +++ b/rack.gemspec @@ -12,7 +12,7 @@ the simplest way possible, it unifies and distills the API for web servers, web frameworks, and software in between (the so-called middleware) into a single method call. -Also see http://rack.github.io/. +Also see https://rack.github.io/. EOF s.files = Dir['{bin/*,contrib/*,example/*,lib/**/*,test/**/*}'] + @@ -25,7 +25,7 @@ EOF s.author = 'Christian Neukirchen' s.email = 'chneukirchen@gmail.com' - s.homepage = 'http://rack.github.io/' + s.homepage = 'https://rack.github.io/' s.required_ruby_version = '>= 2.2.2' s.add_development_dependency 'minitest', "~> 5.0" diff --git a/test/spec_lock.rb b/test/spec_lock.rb index aa3efa54..c6f7c05e 100644 --- a/test/spec_lock.rb +++ b/test/spec_lock.rb @@ -147,7 +147,8 @@ describe Rack::Lock do }, false) env = Rack::MockRequest.env_for("/") env['rack.multithread'].must_equal true - app.call(env) + _, _, body = app.call(env) + body.close env['rack.multithread'].must_equal true end @@ -191,4 +192,13 @@ describe Rack::Lock do lambda { app.call(env) }.must_raise Exception lock.synchronized.must_equal false end + + it "not replace the environment" do + env = Rack::MockRequest.env_for("/") + app = lock_app(lambda { |inner_env| [200, {"Content-Type" => "text/plain"}, [inner_env.object_id.to_s]] }) + + _, _, body = app.call(env) + + body.to_enum.to_a.must_equal [env.object_id.to_s] + end end |