Class: NOMS::Command::UserAgent::Requester::HTTPClient
- Defined in:
- lib/noms/command/useragent/requester/httpclient.rb
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#initialize(opt = {}) ⇒ HTTPClient
constructor
A new instance of HTTPClient.
- #request(opt = {}) ⇒ Object
- #set_auth(domain, username, password) ⇒ Object
Methods inherited from Base
Constructor Details
#initialize(opt = {}) ⇒ HTTPClient
Returns a new instance of HTTPClient.
29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/noms/command/useragent/requester/httpclient.rb', line 29 def initialize(opt={}) @log = opt[:logger] || default_logger @log.debug "Creating #{self.class} with options: #{opt.inspect}" @client_opts = opt @client = ::HTTPClient.new :agent_name => "noms/#{NOMS::Command::VERSION} httpclient/#{::HTTPClient::VERSION}" = opt.has_key?(:cookies) ? opt[:cookies] : true if = File.join(NOMS::Command.home, 'cookies.txt') @client.() else @client. = nil end @client.ssl_config.verify_mode = OpenSSL::SSL::VERIFY_NONE end |
Instance Method Details
#request(opt = {}) ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/noms/command/useragent/requester/httpclient.rb', line 44 def request(opt={}) response = @client.request(opt[:method].to_s.upcase, opt[:url], '', opt[:body], opt[:headers]) noms_response = NOMS::Command::UserAgent::Response::HTTPClient.new(response) if # @client.save_cookie_store - There is a bug where # it thinks @is_saved is satisfied all the time and # the file isn't written, which is why we call # cookie manager directly. @client..(true) end noms_response end |
#set_auth(domain, username, password) ⇒ Object
57 58 59 |
# File 'lib/noms/command/useragent/requester/httpclient.rb', line 57 def set_auth(domain, username, password) @client.set_auth(domain, username, password) end |