Sha256: d00502fb61d2272c8dcae4770a3ee80c4da3466a2cc22f350036dd222ab31f8e
Contents?: true
Size: 1.13 KB
Versions: 7
Compression:
Stored size: 1.13 KB
Contents
module Elastics module HttpClients class Patron < Base 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 private def session Thread.current[:elastics_patron_session] ||= begin sess = ::Patron::Session.new sess.headers['User-Agent'] = "elastics-#{Elastics::VERSION}" sess.base_url = base_uri sess end end end end end
Version data entries
7 entries across 7 versions & 1 rubygems