Skip to content

Commit

Permalink
Restore support for String as URI for #request
Browse files Browse the repository at this point in the history
  • Loading branch information
drbrain committed Oct 5, 2016
1 parent 5bae22e commit 4634c20
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/net/http/persistent.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1012,6 +1012,7 @@ def request uri, req = nil, &block
retried = false
bad_response = false

uri = URI uri
req = request_setup req || uri
response = nil

Expand Down
16 changes: 16 additions & 0 deletions test/test_net_http_persistent.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1350,6 +1350,22 @@ def test_request_setup
assert_equal '30', req['keep-alive']
end

def test_request_string
@http.override_headers['user-agent'] = 'test ua'
@http.headers['accept'] = 'text/*'
c = connection

res = @http.request @uri.to_s
req = c.http.req

assert_kind_of Net::HTTPResponse, res

assert_kind_of Net::HTTP::Get, req
assert_equal '/path', req.path

assert_equal 1, c.requests
end

def test_request_setup_uri
uri = @uri + '?a=b'

Expand Down

0 comments on commit 4634c20

Please sign in to comment.