Class: HTTParty::Request

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

Overview

:nodoc:

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, o = {}) ⇒ Request

Returns a new instance of Request.



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

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

Instance Attribute Details

#http_methodObject

Returns the value of attribute http_method.



7
8
9
# File 'lib/httparty/request.rb', line 7

def http_method
  @http_method
end

#optionsObject

Returns the value of attribute options.



7
8
9
# File 'lib/httparty/request.rb', line 7

def options
  @options
end

#pathObject

Returns the value of attribute path.



7
8
9
# File 'lib/httparty/request.rb', line 7

def path
  @path
end

Instance Method Details

#formatObject



33
34
35
# File 'lib/httparty/request.rb', line 33

def format
  options[:format]
end

#performObject



37
38
39
40
41
# File 'lib/httparty/request.rb', line 37

def perform
  validate
  setup_raw_request
  handle_response(get_response)
end

#uriObject



22
23
24
25
26
27
28
29
30
31
# File 'lib/httparty/request.rb', line 22

def uri
  new_uri = path.relative? ? URI.parse("#{options[:base_uri]}#{path}") : path
  
  # avoid double query string on redirects [#12]
  unless @redirect
    new_uri.query = query_string(new_uri)
  end
  
  new_uri
end