Method: URI::HTTP#request_uri
- Defined in:
- lib/uri/http.rb
#request_uri ⇒ Object
Description
Returns the full path for an HTTP request, as required by Net::HTTP::Get.
If the URI contains a query, the full path is URI#path + ‘?’ + URI#query. Otherwise, the path is simply URI#path.
Example:
uri = URI::HTTP.build(path: '/foo/bar', query: 'test=true')
uri.request_uri # => "/foo/bar?test=true"
77 78 79 80 81 82 |
# File 'lib/uri/http.rb', line 77 def request_uri return unless @path url = @query ? "#@path?#@query" : @path.dup url.start_with?(?/.freeze) ? url : ?/ + url end |