Class: HTTParty::Request

Inherits:
Object
  • Object
show all
Defined in:
lib/httparty/request.rb

Constant Summary collapse

SupportedHTTPMethods =
[Net::HTTP::Get, Net::HTTP::Post, Net::HTTP::Put, Net::HTTP::Delete]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(http_method, path, options = {}) ⇒ Request

Returns a new instance of Request.



7
8
9
10
11
12
13
14
# File 'lib/httparty/request.rb', line 7

def initialize(http_method, path, options={})
  self.http_method = http_method
  self.path = path
  self.options = {
    :limit => options.delete(:no_follow) ? 0 : 5, 
    :default_params => {},
  }.merge(options.dup)
end

Instance Attribute Details

#http_methodObject

Returns the value of attribute http_method.



5
6
7
# File 'lib/httparty/request.rb', line 5

def http_method
  @http_method
end

#optionsObject

Returns the value of attribute options.



5
6
7
# File 'lib/httparty/request.rb', line 5

def options
  @options
end

#pathObject

Returns the value of attribute path.



5
6
7
# File 'lib/httparty/request.rb', line 5

def path
  @path
end

Instance Method Details

#performObject



26
27
28
29
# File 'lib/httparty/request.rb', line 26

def perform
  validate!
  handle_response!(get_response(uri))
end

#uriObject



20
21
22
23
24
# File 'lib/httparty/request.rb', line 20

def uri
  uri = path.relative? ? URI.parse("#{options[:base_uri]}#{path}") : path
  uri.query = query_string(uri)
  uri
end