Class: HTTP::Get

Inherits:
Request show all
Defined in:
lib/http_client/mri/methods.rb,
lib/http_client/jruby/methods.rb

Instance Attribute Summary

Attributes inherited from Request

#body, #encoding

Instance Method Summary collapse

Methods inherited from Request

#add_headers, #basic_auth, #content_type=, #execute_native_request, #initialize, #make_native_request

Constructor Details

This class inherits a constructor from HTTP::Request

Instance Method Details

#create_native_requestObject



69
70
71
72
# File 'lib/http_client/jruby/methods.rb', line 69

def create_native_request
  query_string = URLEncodedUtils.format(@query_params, encoding)
  HttpGet.new(create_uri(query_string))
end

#create_requestObject



52
53
54
55
56
# File 'lib/http_client/mri/methods.rb', line 52

def create_request
  host, port, path, query = parse_uri
  get = Net::HTTP::Get.new("#{path}?#{query || to_query_string(@params)}")
  [host, port, get]
end

#to_query_string(params_as_hash) ⇒ Object



58
59
60
# File 'lib/http_client/mri/methods.rb', line 58

def to_query_string(params_as_hash)
  params_as_hash.map { |name, value| "#{URI.encode(name.to_s)}=#{URI.encode(value.to_s)}" }.join("&")
end