Class: Parse::PatronHttpClient
- Inherits:
-
HttpClient
- Object
- HttpClient
- Parse::PatronHttpClient
- Defined in:
- lib/parse/http_client.rb
Instance Method Summary collapse
- #base_url ⇒ Object
- #base_url=(url) ⇒ Object
- #build_query(hash) ⇒ Object
- #headers ⇒ Object
- #headers=(hash) ⇒ Object
-
#initialize(base_url = nil, headers = {}) ⇒ PatronHttpClient
constructor
A new instance of PatronHttpClient.
- #request(method, uri, headers, options) ⇒ Object
Constructor Details
#initialize(base_url = nil, headers = {}) ⇒ PatronHttpClient
Returns a new instance of PatronHttpClient.
48 49 50 51 52 53 54 |
# File 'lib/parse/http_client.rb', line 48 def initialize(base_url=nil, headers = {}) super @session = Patron::Session.new @session.timeout = 30 @session.connect_timeout = 30 @session.headers.update(@headers) end |
Instance Method Details
#base_url ⇒ Object
66 67 68 |
# File 'lib/parse/http_client.rb', line 66 def base_url @session.base_url end |
#base_url=(url) ⇒ Object
70 71 72 |
# File 'lib/parse/http_client.rb', line 70 def base_url=(url) @session.base_url = url end |
#build_query(hash) ⇒ Object
56 57 58 |
# File 'lib/parse/http_client.rb', line 56 def build_query(hash) Patron::Util.build_query_pairs_from_hash(hash).join('&') end |
#headers ⇒ Object
74 75 76 |
# File 'lib/parse/http_client.rb', line 74 def headers @session.headers end |
#headers=(hash) ⇒ Object
78 79 80 |
# File 'lib/parse/http_client.rb', line 78 def headers=(hash) @session.headers = hash end |
#request(method, uri, headers, options) ⇒ Object
60 61 62 63 64 |
# File 'lib/parse/http_client.rb', line 60 def request(method, uri, headers, ) @session.request(method, uri, headers, ) rescue Patron::TimeoutError => e raise HttpClient::TimeoutError.new(e) end |