Skip to content

Commit 092e3cc

Browse files
committed
Remove Rack::HttpStreamingResponse monkey-patch by upgrading rack-proxy
- In v0.5.14 Rack::HttpStreamingResponse#read_timeout= was added, see ncr/rack-proxy@42e32e3 - Easier to upgrade dependency than to maintain patching of external dependency
1 parent c15e2b6 commit 092e3cc

File tree

4 files changed

+4
-12
lines changed

4 files changed

+4
-12
lines changed

lib/rack/reverse_proxy.rb

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

87
module Rack
98
class ReverseProxy
@@ -77,7 +76,7 @@ def proxy(env, source_request, matcher)
7776
target_response = HttpStreamingResponse.new(target_request, uri.host, uri.port)
7877

7978
# pass the timeout configuration through
80-
target_response.set_read_timeout(options[:timeout]) if options[:timeout].to_i > 0
79+
target_response.read_timeout = options[:timeout] if options[:timeout].to_i > 0
8180

8281
target_response.use_ssl = "https" == uri.scheme
8382

lib/rack/reverse_proxy/http_streaming_response.rb

Lines changed: 0 additions & 7 deletions
This file was deleted.

rack-reverse-proxy.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@ Gem::Specification.new do |s|
1414
s.add_development_dependency "guard-bundler"
1515

1616
s.add_dependency "rack", ">= 1.0.0"
17-
s.add_dependency "rack-proxy", "~> 0.5"
17+
s.add_dependency "rack-proxy", "~> 0.5", ">= 0.5.14"
1818
end

spec/rack/reverse_proxy_spec.rb

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

146146
it "should make request with basic auth" do
147147
stub_request(:get, "http://example.com/test/slow")
148-
Rack::HttpStreamingResponse.any_instance.should_receive(:set_read_timeout).with(99)
148+
Rack::HttpStreamingResponse.any_instance.should_receive(:read_timeout=).with(99)
149149
get '/test/slow'
150150
end
151151
end
@@ -159,7 +159,7 @@ def app
159159

160160
it "should make request with basic auth" do
161161
stub_request(:get, "http://example.com/test/slow")
162-
Rack::HttpStreamingResponse.any_instance.should_not_receive(:set_read_timeout)
162+
Rack::HttpStreamingResponse.any_instance.should_not_receive(:read_timeout=)
163163
get '/test/slow'
164164
end
165165
end

0 commit comments

Comments
 (0)