Skip to content

Commit f0458c9

Browse files
committed
quickfix for jruby + rack-reverse-proxy + rspec-mocks + :read_timeout= weirdness
1 parent 0ef1631 commit f0458c9

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

lib/rack/reverse_proxy.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
require "rack-proxy"
44
require "rack/reverse_proxy_matcher"
55
require "rack/exception"
6+
require "rack/reverse_proxy/http_streaming_response"
67

78
module Rack
89
class ReverseProxy
@@ -72,7 +73,7 @@ def proxy(env, source_request, matcher)
7273
target_response = HttpStreamingResponse.new(target_request, uri.host, uri.port)
7374

7475
# pass the timeout configuration through
75-
target_response.read_timeout = options[:timeout] if options[:timeout].to_i > 0
76+
target_response.set_read_timeout(options[:timeout]) if options[:timeout].to_i > 0
7677

7778
target_response.use_ssl = "https" == uri.scheme
7879

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
module Rack
2+
class HttpStreamingResponse
3+
def set_read_timeout(value)
4+
self.read_timeout = value
5+
end
6+
end
7+
end

spec/rack/reverse_proxy_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ def app
8989

9090
it "should make request with basic auth" do
9191
stub_request(:get, "http://example.com/test/slow")
92-
Rack::HttpStreamingResponse.any_instance.should_receive(:read_timeout=).with(99)
92+
Rack::HttpStreamingResponse.any_instance.should_receive(:set_read_timeout).with(99)
9393
get '/test/slow'
9494
end
9595
end
@@ -103,7 +103,7 @@ def app
103103

104104
it "should make request with basic auth" do
105105
stub_request(:get, "http://example.com/test/slow")
106-
Rack::HttpStreamingResponse.any_instance.should_not_receive(:read_timeout=)
106+
Rack::HttpStreamingResponse.any_instance.should_not_receive(:set_read_timeout)
107107
get '/test/slow'
108108
end
109109
end

0 commit comments

Comments
 (0)