Class: Tweakphoeus::Client
- Inherits:
-
Object
- Object
- Tweakphoeus::Client
- Defined in:
- lib/tweakphoeus.rb
Overview
Http client class
Instance Attribute Summary collapse
-
#base_headers ⇒ Object
Returns the value of attribute base_headers.
-
#cookie_jar ⇒ Object
Returns the value of attribute cookie_jar.
-
#redirect ⇒ Object
Returns the value of attribute redirect.
-
#referer_list ⇒ Object
Returns the value of attribute referer_list.
-
#ssl_verifypeer ⇒ Object
readonly
Returns the value of attribute ssl_verifypeer.
Instance Method Summary collapse
- #delete(url, body: nil, headers: nil) ⇒ Object
- #get(url, body: nil, params: nil, headers: nil) ⇒ Object
-
#initialize(ua_systems: %i[linux mac],, ssl_verifypeer: true, redirect: false) ⇒ Client
constructor
A new instance of Client.
- #post(url, body: nil, headers: nil) ⇒ Object
- #set_proxy(url, auth) ⇒ Object
- #unset_proxy ⇒ Object
Constructor Details
#initialize(ua_systems: %i[linux mac],, ssl_verifypeer: true, redirect: false) ⇒ Client
Returns a new instance of Client.
15 16 17 18 19 20 21 22 23 |
# File 'lib/tweakphoeus.rb', line 15 def initialize(ua_systems: i[linux mac], ssl_verifypeer: true, redirect: false) = Tweakphoeus::CookieJar.new @referer_list = Tweakphoeus::RefererList.new @redirect = redirect @base_headers = build_base_headers(ua_systems) @proxy = nil @proxyuserpwd = nil @ssl_verifypeer = ssl_verifypeer end |
Instance Attribute Details
#base_headers ⇒ Object
Returns the value of attribute base_headers.
12 13 14 |
# File 'lib/tweakphoeus.rb', line 12 def base_headers @base_headers end |
#cookie_jar ⇒ Object
Returns the value of attribute cookie_jar.
12 13 14 |
# File 'lib/tweakphoeus.rb', line 12 def end |
#redirect ⇒ Object
Returns the value of attribute redirect.
12 13 14 |
# File 'lib/tweakphoeus.rb', line 12 def redirect @redirect end |
#referer_list ⇒ Object
Returns the value of attribute referer_list.
12 13 14 |
# File 'lib/tweakphoeus.rb', line 12 def referer_list @referer_list end |
#ssl_verifypeer ⇒ Object (readonly)
Returns the value of attribute ssl_verifypeer.
13 14 15 |
# File 'lib/tweakphoeus.rb', line 13 def ssl_verifypeer @ssl_verifypeer end |
Instance Method Details
#delete(url, body: nil, headers: nil) ⇒ Object
30 31 32 33 |
# File 'lib/tweakphoeus.rb', line 30 def delete(url, body: nil, headers: nil) referer_list.referer_from_headers(headers) http_request(url, body: body, headers: headers, method: :delete) end |
#get(url, body: nil, params: nil, headers: nil) ⇒ Object
25 26 27 28 |
# File 'lib/tweakphoeus.rb', line 25 def get(url, body: nil, params: nil, headers: nil) referer_list.referer_from_headers(headers) http_request(url, body: body, params: params, headers: headers, method: :get) end |
#post(url, body: nil, headers: nil) ⇒ Object
35 36 37 38 |
# File 'lib/tweakphoeus.rb', line 35 def post(url, body: nil, headers: nil) referer_list.referer_from_headers(headers) http_request(url, body: body, headers: headers, method: :post) end |
#set_proxy(url, auth) ⇒ Object
40 41 42 43 44 45 |
# File 'lib/tweakphoeus.rb', line 40 def set_proxy(url, auth) return unless auth @proxyuserpwd = "#{auth[:user]}:#{auth[:password]}" @proxy = url end |
#unset_proxy ⇒ Object
47 48 49 50 |
# File 'lib/tweakphoeus.rb', line 47 def unset_proxy @proxyuserpwd = nil @proxy = nil end |