Module: Typhoeus::Request::Operations
- Included in:
- Typhoeus::Request
- Defined in:
- lib/typhoeus/request/operations.rb
Overview
This module contains everything what is necessary to make a single request.
Instance Method Summary collapse
-
#finish(response, bypass_memoization = nil) ⇒ Typhoeus::Response
Sets a response, the request on the response and executes the callbacks.
-
#run ⇒ Response
Run a request.
Instance Method Details
permalink #finish(response, bypass_memoization = nil) ⇒ Typhoeus::Response
Sets a response, the request on the response and executes the callbacks.
41 42 43 44 45 46 47 48 49 50 |
# File 'lib/typhoeus/request/operations.rb', line 41 def finish(response, bypass_memoization = nil) if bypass_memoization @response = response else self.response = response end self.response.request = self execute_callbacks response end |
permalink #run ⇒ Response
Run a request.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/typhoeus/request/operations.rb', line 14 def run easy = Typhoeus.get_easy begin easy.http_request( url, .fetch(:method, :get), .reject{|k,_| k==:method} ) rescue Ethon::Errors::InvalidOption => e help = provide_help(e..match(/:\s(\w+)/)[1]) raise $!, "#{$!}#{help}", $!.backtrace end easy.prepare easy.perform finish(Response.new(easy.to_hash)) Typhoeus.release_easy(easy) response end |