Class: BrownPaperTickets::Httpost
- Inherits:
-
HTTParty::Request
- Object
- HTTParty::Request
- BrownPaperTickets::Httpost
- Defined in:
- lib/brownpapertickets/httpost.rb
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 = {}) ⇒ Httpost
constructor
A new instance of Httpost.
- #parser ⇒ Object
- #perform ⇒ Object
- #uri ⇒ Object
Constructor Details
#initialize(http_method, path, o = {}) ⇒ Httpost
Returns a new instance of Httpost.
17 18 19 |
# File 'lib/brownpapertickets/httpost.rb', line 17 def initialize(http_method, path, o={}) super end |
Instance Attribute Details
#http_method ⇒ Object
Returns the value of attribute http_method.
15 16 17 |
# File 'lib/brownpapertickets/httpost.rb', line 15 def http_method @http_method end |
#last_response ⇒ Object
Returns the value of attribute last_response.
15 16 17 |
# File 'lib/brownpapertickets/httpost.rb', line 15 def last_response @last_response end |
#options ⇒ Object
Returns the value of attribute options.
15 16 17 |
# File 'lib/brownpapertickets/httpost.rb', line 15 def @options end |
#path ⇒ Object
Returns the value of attribute path.
15 16 17 |
# File 'lib/brownpapertickets/httpost.rb', line 15 def path @path end |
#redirect ⇒ Object
Returns the value of attribute redirect.
15 16 17 |
# File 'lib/brownpapertickets/httpost.rb', line 15 def redirect @redirect end |
Instance Method Details
#format ⇒ Object
40 41 42 |
# File 'lib/brownpapertickets/httpost.rb', line 40 def format [:format] || (format_from_mimetype(last_response['content-type']) if last_response) end |
#parser ⇒ Object
44 45 46 |
# File 'lib/brownpapertickets/httpost.rb', line 44 def parser [:parser] end |
#perform ⇒ Object
48 49 50 51 52 53 54 |
# File 'lib/brownpapertickets/httpost.rb', line 48 def perform validate setup_raw_request get_response return self.last_response #handle_response end |
#uri ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/brownpapertickets/httpost.rb', line 25 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 |