Skip to content

Commit ca47360

Browse files
committed
Merge branch 'master' of https://github.com/jasonheecs/httparty into jasonheecs-master
2 parents b9bd421 + 01534e5 commit ca47360

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

lib/httparty/request.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ def handle_redirection(&block)
341341
def handle_host_redirection
342342
check_duplicate_location_header
343343
redirect_path = options[:uri_adapter].parse(last_response['location']).normalize
344-
return if redirect_path.relative? || path.host == redirect_path.host
344+
return if redirect_path.relative? || path.host == redirect_path.host || uri.host == redirect_path.host
345345
@changed_hosts = true
346346
end
347347

spec/httparty/request_spec.rb

+14
Original file line numberDiff line numberDiff line change
@@ -1369,6 +1369,20 @@
13691369
@request.send(:setup_raw_request)
13701370
expect(@request.instance_variable_get(:@raw_request)['authorization']).to eq(@authorization)
13711371
end
1372+
1373+
context 'when uri path is a relative path' do
1374+
before do
1375+
@request.path = '/v1'
1376+
@request.options[:base_uri] = 'http://api.foo.com'
1377+
end
1378+
1379+
it "should send Authorization header when redirecting to the same host" do
1380+
@redirect['location'] = 'http://api.foo.com/v2'
1381+
@request.perform
1382+
@request.send(:setup_raw_request)
1383+
expect(@request.instance_variable_get(:@raw_request)['authorization']).to eq(@authorization)
1384+
end
1385+
end
13721386
end
13731387
end
13741388

0 commit comments

Comments
 (0)