Module: Gnarly::Client::Typhoeus
- Defined in:
- lib/gnarly/client/typhoeus.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.http(request, opts = {}) ⇒ Object
30 31 32 |
# File 'lib/gnarly/client/typhoeus.rb', line 30 def self.http(request, opts={}) Object.new.extend(self).http request, opts end |
Instance Method Details
#http(request, opts = {}) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/gnarly/client/typhoeus.rb', line 11 def http(request, opts={}) method, url, headers, body = request = {:headers => headers} case url when Array url, query = url [:params] = query end [:body] = body if body [:timeout] = opts[:timeout] * 1000 if opts[:timeout] r = ::Typhoeus::Request.send method, url, response = [r.code, Client.symbolize_headers(r.headers_hash), r.body] if block_given? yield response else response end end |