Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

fix the bug under new rack version >=1.4.1 #4

Open
wants to merge 1 commit into from

3 participants

@fuying

Rack version >=1.4.1 add BodyProxy to do thread lock, which need sham_rack to close the BodyProxy manually. I modified the net_http.rb file to fix the problem.

@mdub
Owner

Hi Fu Ying. Thanks for the pull request.

I would like a test, though, that demonstrates the bug under newer versions of Rack. Is it easy to reproduce?

FWIW, I've now got sham_rack's tests running against multiple versions of the rack gem, on Travis CI. See: https://travis-ci.org/mdub/sham_rack

Also, I'm not comfortable with your Gemfile change, as I would like sham_rack to continue to be usable with older versions of rack. I suspect there's some way we can avoid requiring the new "Rack::BodyProxy" class, perhaps by using a respond_to? check, rather than instance_of?.

@fuying

Hi Mike. Very glad to see your reply.

The error we meet is come from the lock mechanism of new version rack. I haven't find the simple way to reproduce it. In our system, we use cucumber, httparty to call method in sham_rack. There are two request are sent out continuous, the first one will lock the thread which will make the second got an error about thread.

I will keep trying to reproduce it when I have time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 3 additions and 1 deletion.
  1. +2 −0  lib/sham_rack/net_http.rb
  2. +1 −1  sham_rack.gemspec
View
2  lib/sham_rack/net_http.rb
@@ -1,5 +1,6 @@
require "net/http"
require "rack"
+require "rack/body_proxy"
require "sham_rack/registry"
class << Net::HTTP
@@ -85,6 +86,7 @@ def build_response(rack_response)
end
def assemble_body(body)
+ body.close if body.instance_of? Rack::BodyProxy
content = ""
body.each { |fragment| content << fragment }
content
View
2  sham_rack.gemspec
@@ -16,7 +16,7 @@ Gem::Specification.new do |gem|
gem.version = ShamRack::VERSION.dup
gem.platform = Gem::Platform::RUBY
- gem.add_dependency "rack"
+ gem.add_dependency "rack", ">= 1.4.1"
gem.require_path = "lib"
gem.files = Dir["lib/**/*", "README.markdown", "CHANGES.markdown"]
Something went wrong with that request. Please try again.