Method: Mechanize::HTTP::Agent#request_auth

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

#request_auth(request, uri) ⇒ Object


605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
# File 'lib/mechanize/http/agent.rb', line 605

def request_auth request, uri
  base_uri = uri + '/'
  base_uri.user     &&= nil
  base_uri.password &&= nil
  schemes = @authenticate_methods[base_uri]

  if realm = schemes[:digest].find { |r| r.uri == base_uri } then
    request_auth_digest request, uri, realm, base_uri, false
  elsif realm = schemes[:iis_digest].find { |r| r.uri == base_uri } then
    request_auth_digest request, uri, realm, base_uri, true
  elsif realm = schemes[:basic].find { |r| r.uri == base_uri } then
    user, password, = @auth_store.credentials_for uri, realm.realm
    request.basic_auth user, password
  end
end