Class: HTTParty::Request
- Inherits:
-
Object
- Object
- HTTParty::Request
- Defined in:
- lib/httparty/request.rb
Overview
:nodoc:
Constant Summary collapse
- SupportedHTTPMethods =
[ Net::HTTP::Get, Net::HTTP::Post, Net::HTTP::Put, Net::HTTP::Delete, Net::HTTP::Head, Net::HTTP::Options ]
- SupportedURISchemes =
[URI::HTTP, URI::HTTPS]
Instance Attribute Summary collapse
-
#http_method ⇒ Object
Returns the value of attribute http_method.
-
#last_response ⇒ Object
Returns the value of attribute last_response.
-
#options ⇒ Object
Returns the value of attribute options.
-
#path ⇒ Object
Returns the value of attribute path.
-
#redirect ⇒ Object
Returns the value of attribute redirect.
Instance Method Summary collapse
- #format ⇒ Object
-
#initialize(http_method, path, o = {}) ⇒ Request
constructor
A new instance of Request.
- #parser ⇒ Object
- #perform ⇒ Object
- #uri ⇒ Object
Constructor Details
#initialize(http_method, path, o = {}) ⇒ Request
Returns a new instance of Request.
18 19 20 21 22 23 24 25 26 |
# File 'lib/httparty/request.rb', line 18 def initialize(http_method, path, o={}) self.http_method = http_method self.path = path self. = { :limit => o.delete(:no_follow) ? 1 : 5, :default_params => {}, :parser => Parser }.merge(o) end |
Instance Attribute Details
#http_method ⇒ Object
Returns the value of attribute http_method.
16 17 18 |
# File 'lib/httparty/request.rb', line 16 def http_method @http_method end |
#last_response ⇒ Object
Returns the value of attribute last_response.
16 17 18 |
# File 'lib/httparty/request.rb', line 16 def last_response @last_response end |
#options ⇒ Object
Returns the value of attribute options.
16 17 18 |
# File 'lib/httparty/request.rb', line 16 def @options end |
#path ⇒ Object
Returns the value of attribute path.
16 17 18 |
# File 'lib/httparty/request.rb', line 16 def path @path end |
#redirect ⇒ Object
Returns the value of attribute redirect.
16 17 18 |
# File 'lib/httparty/request.rb', line 16 def redirect @redirect end |
Instance Method Details
#format ⇒ Object
47 48 49 |
# File 'lib/httparty/request.rb', line 47 def format [:format] end |
#parser ⇒ Object
51 52 53 |
# File 'lib/httparty/request.rb', line 51 def parser [:parser] end |
#perform ⇒ Object
55 56 57 58 59 60 |
# File 'lib/httparty/request.rb', line 55 def perform validate setup_raw_request get_response handle_response end |
#uri ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/httparty/request.rb', line 32 def uri new_uri = path.relative? ? URI.parse("#{[:base_uri]}#{path}") : path # avoid double query string on redirects [#12] unless redirect new_uri.query = query_string(new_uri) end unless SupportedURISchemes.include? new_uri.class raise UnsupportedURIScheme, "'#{new_uri}' Must be HTTP or HTTPS" end new_uri end |