Class: HTTP::Options

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



83
84
85
86
# File 'lib/http_client/jruby/methods.rb', line 83

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

#create_requestObject



76
77
78
79
80
# File 'lib/http_client/mri/methods.rb', line 76

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

#to_query_string(params_as_hash) ⇒ Object



82
83
84
# File 'lib/http_client/mri/methods.rb', line 82

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