Class: HTTP::Head

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



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

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

#create_requestObject



64
65
66
67
68
# File 'lib/http_client/mri/methods.rb', line 64

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

#to_query_string(params_as_hash) ⇒ Object



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

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