Class: Mechanize::HTTP::AuthChallenge

Inherits:
Struct
  • Object
show all
Defined in:
lib/mechanize/http/auth_challenge.rb,
lib/mechanize/http/auth_challenge.rb

Overview

A parsed WWW-Authenticate header

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#paramsObject

Returns the value of attribute params

Returns:

  • (Object)

    the current value of params



4
5
6
# File 'lib/mechanize/http/auth_challenge.rb', line 4

def params
  @params
end

#rawObject Also known as: to_s

Returns the value of attribute raw

Returns:

  • (Object)

    the current value of raw



4
5
6
# File 'lib/mechanize/http/auth_challenge.rb', line 4

def raw
  @raw
end

#schemeObject

Returns the value of attribute scheme

Returns:

  • (Object)

    the current value of scheme



4
5
6
# File 'lib/mechanize/http/auth_challenge.rb', line 4

def scheme
  @scheme
end

Instance Method Details

#[](param) ⇒ Object

Retrieves param from the params list



32
33
34
# File 'lib/mechanize/http/auth_challenge.rb', line 32

def [] param
  params[param]
end

#realm(uri) ⇒ Object

Constructs an AuthRealm for this challenge



39
40
41
42
43
44
45
46
47
48
49
# File 'lib/mechanize/http/auth_challenge.rb', line 39

def realm uri
  case scheme
  when 'Basic' then
    raise ArgumentError, "provide uri for Basic authentication" unless uri
    Mechanize::HTTP::AuthRealm.new scheme, uri + '/', self['realm']
  when 'Digest' then
    Mechanize::HTTP::AuthRealm.new scheme, uri + '/', self['realm']
  else
    raise Mechanize::Error, "unknown HTTP authentication scheme #{scheme}"
  end
end

#realm_nameObject

The name of the realm for this challenge



54
55
56
# File 'lib/mechanize/http/auth_challenge.rb', line 54

def realm_name
  params['realm'] if Hash === params # NTLM has a string for params
end