Class: Flex::HttpClients::Patron

Inherits:
Base
  • Object
show all
Defined in:
lib/flex/http_clients/patron.rb

Instance Attribute Summary

Attributes inherited from Base

#base_uri, #options, #raise_proc

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Flex::HttpClients::Base

Instance Method Details

#request(method, path, data = nil) ⇒ Object



5
6
7
8
9
10
11
12
13
14
# File 'lib/flex/http_clients/patron.rb', line 5

def request(method, path, data=nil)
  # patron would raise an error for :post and :put requests with no data
  # and elasticsearch ignores the data when it expects no data,
  # so we silence patron by adding some dummy data
  data = {} if (method == 'POST' || method == 'PUT') && data.nil?
  opts = options.merge(:data => data)
  session.request method.to_s.downcase.to_sym, path, {}, opts
rescue ::Patron::TimeoutError
  session.request method.to_s.downcase.to_sym, path, {}, opts
end