Skip to content

Commit 80a5f7f

Browse files
committed
Merge pull request #2 from waterlink/anujdas/1.8-compat
Fix method declaration to be ruby-1.8-compatible
2 parents 6c72574 + f0458c9 commit 80a5f7f

File tree

4 files changed

+14
-6
lines changed

4 files changed

+14
-6
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

lib/rack/reverse_proxy_matcher.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module Rack
22
class ReverseProxyMatcher
3-
def initialize(matcher,url=nil,options)
3+
def initialize(matcher, url=nil, options={})
44
@default_url=url
55
@url=url
66
@options=options

spec/rack/reverse_proxy_spec.rb

Lines changed: 4 additions & 4 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
@@ -324,9 +324,9 @@ def app
324324

325325
it "should proxy requests when a pattern is matched" do
326326
stub_request(:get, 'http://users-example.com/users?user=omer').to_return({:body => "User App"})
327-
get '/test', user: "mark"
327+
get '/test', :user => "mark"
328328
last_response.body.should == "Dummy App"
329-
get '/users', user: 'omer'
329+
get '/users', :user => 'omer'
330330
last_response.body.should == "User App"
331331
end
332332
end

0 commit comments

Comments
 (0)