Module: Wpxf::Net::TyphoeusHelper
- Included in:
- HttpClient
- Defined in:
- lib/wpxf/net/typhoeus_helper.rb
Overview
Provides helper functions for interfacing with Typhoeus in a module.
Instance Method Summary collapse
- #advanced_typhoeus_options ⇒ Object
- #create_typhoeus_request(opts) ⇒ Object
- #create_typhoeus_request_options(method, params, body, headers) ⇒ Object
- #standard_typhoeus_options(method, params, body, headers) ⇒ Object
Instance Method Details
#advanced_typhoeus_options ⇒ Object
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/wpxf/net/typhoeus_helper.rb', line 7 def { userpwd: datastore['basic_auth_creds'], proxy: datastore['proxy'], proxyuserpwd: datastore['proxy_auth_creds'], ssl_verifyhost: normalized_option_value('verify_host') ? 2 : 0, ssl_verifypeer: normalized_option_value('verify_peer'), timeout: normalized_option_value('http_client_timeout') } end |
#create_typhoeus_request(opts) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/wpxf/net/typhoeus_helper.rb', line 33 def create_typhoeus_request(opts) headers = opts[:headers] || {} headers['Cookie'] = opts[:cookie] if opts[:cookie] = ( opts[:method], opts[:params], opts[:body], headers ) Typhoeus::Request.new(normalize_relative_uri(opts[:url]), ) end |
#create_typhoeus_request_options(method, params, body, headers) ⇒ Object
28 29 30 31 |
# File 'lib/wpxf/net/typhoeus_helper.rb', line 28 def (method, params, body, headers) (method, params, body, headers) .merge() end |
#standard_typhoeus_options(method, params, body, headers) ⇒ Object
18 19 20 21 22 23 24 25 26 |
# File 'lib/wpxf/net/typhoeus_helper.rb', line 18 def (method, params, body, headers) { method: method, body: body, params: params, headers: base_http_headers.merge(headers), followlocation: normalized_option_value('follow_http_redirection') } end |