Skip to content

Commit a587935

Browse files
committed
Merge pull request #9 from sportngin/fix_url_handling
Better use the provided url when proxying requests
2 parents cc90c0c + 2200d1b commit a587935

File tree

5 files changed

+9
-9
lines changed

5 files changed

+9
-9
lines changed

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.6.2
1+
0.7.0

lib/rack/reverse_proxy.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def proxy(env, source_request, matcher)
3737
options = @global_options.dup.merge(matcher.options)
3838

3939
# Initialize request
40-
target_request = Net::HTTP.const_get(source_request.request_method.capitalize).new(source_request.fullpath)
40+
target_request = Net::HTTP.const_get(source_request.request_method.capitalize).new(uri.request_uri)
4141

4242
# Setup headers
4343
target_request_headers = extract_http_request_headers(source_request.env)

lib/rack/reverse_proxy_matcher.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ def get_uri(path,env)
2626
match_path(path).to_a.each_with_index { |m, i| _url.gsub!("$#{i.to_s}", m) }
2727
URI(_url)
2828
else
29-
_url.include?(path) ? URI.parse(_url) : URI.join(_url, path)
29+
default_url.nil? ? URI.parse(_url) : URI.join(_url, path)
3030
end
3131
end
32-
32+
3333
def to_s
3434
%Q("#{matcher.to_s}" => "#{url}")
3535
end

rack-reverse-proxy.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Gem::Specification.new do |s|
22
s.name = %q{rack-reverse-proxy}
3-
s.version = "0.6.0"
3+
s.version = "0.7.0"
44

55
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
66
s.authors = ["Jon Swope"]

spec/rack/reverse_proxy_spec.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ def app
148148
end
149149

150150
it "should support subcaptures" do
151-
stub_request(:get, 'http://example.com/test/path').to_return({:body => "Proxied App"})
151+
stub_request(:get, 'http://example.com/path').to_return({:body => "Proxied App"})
152152
get '/test/path'
153153
last_response.body.should == "Proxied App"
154154
end
@@ -233,9 +233,9 @@ def self.match(path)
233233

234234
def url(path)
235235
if path.include?("user")
236-
'http://users-example.com/'
236+
'http://users-example.com' + path
237237
else
238-
'http://example.com/'
238+
'http://example.com' + path
239239
end
240240
end
241241
end
@@ -271,7 +271,7 @@ def self.match(path, headers)
271271
end
272272

273273
def url(path)
274-
'http://example.com/'
274+
'http://example.com' + path
275275
end
276276
end
277277

0 commit comments

Comments
 (0)