Class: Mechanize::HTTP::AuthChallenge
- Inherits:
-
Struct
- Object
- Struct
- Mechanize::HTTP::AuthChallenge
- Defined in:
- lib/mechanize/http/auth_challenge.rb,
lib/mechanize/http/auth_challenge.rb
Overview
A parsed WWW-Authenticate header
Instance Attribute Summary collapse
-
#params ⇒ Object
Returns the value of attribute params.
-
#scheme ⇒ Object
Returns the value of attribute scheme.
Instance Method Summary collapse
-
#[](param) ⇒ Object
Retrieves
param
from the params list. -
#realm(uri) ⇒ Object
Constructs an AuthRealm for this challenge.
-
#to_s ⇒ Object
The reconstructed, normalized challenge.
Instance Attribute Details
#params ⇒ Object
Returns the value of attribute params
3 4 5 |
# File 'lib/mechanize/http/auth_challenge.rb', line 3 def params @params end |
#scheme ⇒ Object
Returns the value of attribute scheme
3 4 5 |
# File 'lib/mechanize/http/auth_challenge.rb', line 3 def scheme @scheme end |
Instance Method Details
#[](param) ⇒ Object
Retrieves param
from the params list
28 29 30 |
# File 'lib/mechanize/http/auth_challenge.rb', line 28 def [] param params[param] end |
#realm(uri) ⇒ Object
Constructs an AuthRealm for this challenge
35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/mechanize/http/auth_challenge.rb', line 35 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 |
#to_s ⇒ Object
The reconstructed, normalized challenge
50 51 52 53 54 |
# File 'lib/mechanize/http/auth_challenge.rb', line 50 def to_s auth_params = params.map { |name, value| "#{name}=\"#{value}\"" } "#{scheme} #{auth_params.join ', '}" end |