Method: Mechanize::HTTP::AuthStore#add_auth

Defined in:
lib/mechanize/http/auth_store.rb

#add_auth(uri, user, pass, realm = nil, domain = nil) ⇒ Object

Adds credentials user, pass for the server at uri. If realm is set the credentials are used only for that realm. If realm is not set the credentials become the default for any realm on that URI.

domain and realm are exclusive as NTLM does not follow RFC

  1. If domain is given it is only used for NTLM authentication.

Raises:

  • (ArgumentError)

41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/mechanize/http/auth_store.rb', line 41

def add_auth uri, user, pass, realm = nil, domain = nil
  uri = URI uri unless URI === uri

  raise ArgumentError,
        'NTLM domain given with realm which NTLM does not use' if
    realm and domain

  uri += '/'

  auth_accounts[uri][realm] = [user, pass, domain]

  self
end