Method: HTTPClient::BasicAuth#set

Defined in:
lib/httpclient/auth.rb

#set(uri, user, passwd) ⇒ Object

Set authentication credential. uri == nil for generic purpose (allow to use user/password for any URL).



264
265
266
267
268
269
270
271
272
273
# File 'lib/httpclient/auth.rb', line 264

def set(uri, user, passwd)
  synchronize do
    if uri.nil?
      @cred = ["#{user}:#{passwd}"].pack('m').tr("\n", '')
    else
      uri = Util.uri_dirname(uri)
      @auth[uri] = ["#{user}:#{passwd}"].pack('m').tr("\n", '')
    end
  end
end