Skip to content

Commit 3497b74

Browse files
committed
Merge pull request jaswope#9 from tolingo/feature/remove-http-streaming-patch
Remove Rack::HttpStreamingResponse monkey-patch by upgrading rack-proxy
2 parents 634918a + c8083a2 commit 3497b74

File tree

5 files changed

+19
-14
lines changed

5 files changed

+19
-14
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: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,17 @@ def dummy_app
1111
lambda { |env| [200, {}, ['Dummy App']] }
1212
end
1313

14+
let(:http_streaming_response) {
15+
double(
16+
"Rack::HttpStreamingResponse",
17+
:use_ssl= => nil,
18+
:verify_mode= => nil,
19+
:headers => {},
20+
:status => 200,
21+
:body => "OK"
22+
)
23+
}
24+
1425
describe "as middleware" do
1526
def app
1627
Rack::ReverseProxy.new(dummy_app) do
@@ -145,7 +156,8 @@ def app
145156

146157
it "should make request with basic auth" do
147158
stub_request(:get, "http://example.com/test/slow")
148-
Rack::HttpStreamingResponse.any_instance.should_receive(:set_read_timeout).with(99)
159+
allow(Rack::HttpStreamingResponse).to receive(:new).and_return(http_streaming_response)
160+
expect(http_streaming_response).to receive(:read_timeout=).with(99)
149161
get '/test/slow'
150162
end
151163
end
@@ -159,7 +171,8 @@ def app
159171

160172
it "should make request with basic auth" do
161173
stub_request(:get, "http://example.com/test/slow")
162-
Rack::HttpStreamingResponse.any_instance.should_not_receive(:set_read_timeout)
174+
allow(Rack::HttpStreamingResponse).to receive(:new).and_return(http_streaming_response)
175+
expect(http_streaming_response).not_to receive(:read_timeout=)
163176
get '/test/slow'
164177
end
165178
end

spec/spec_helper.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@
1313
config.expect_with :rspec do |expectations|
1414
# This option will default to `true` in RSpec 4.
1515
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
16-
expectations.syntax = [:should]
16+
expectations.syntax = [:should, :expect]
1717
end
1818
config.mock_with :rspec do |mocks|
1919
mocks.verify_doubled_constant_names = true
2020
mocks.verify_partial_doubles = true
21-
mocks.syntax = [:should]
21+
mocks.syntax = [:should, :expect]
2222
# Prevents you from mocking or stubbing a method that does not exist on
2323
# a real object. This is generally recommended, and will default to
2424
# `true` in RSpec 4.

0 commit comments

Comments
 (0)