add return type
parent
d6d8f68cd1
commit
8fea4adf85
|
@ -259,7 +259,7 @@ class Mechanize
|
|||
target_url
|
||||
end
|
||||
|
||||
private def response_authenticate(response, page, uri, params, referer)
|
||||
private def response_authenticate(response, page, uri, params, referer) : Page
|
||||
www_authenticate = response.headers["www-authenticate"]
|
||||
|
||||
unless www_authenticate = response.headers["www-authenticate"]
|
||||
|
|
|
@ -16,7 +16,7 @@ class Mechanize
|
|||
@raw = raw
|
||||
end
|
||||
|
||||
def [](param)
|
||||
def [](param) : String?
|
||||
params_value = params
|
||||
if params_value.is_a?(Hash)
|
||||
params_value[param] # NTLM has a string for params
|
||||
|
@ -28,15 +28,15 @@ class Mechanize
|
|||
##
|
||||
# Constructs an AuthRealm for this challenge
|
||||
|
||||
def realm(uri)
|
||||
def realm(uri) : AuthRealm
|
||||
target_uri = uri.dup
|
||||
target_uri.path = "/"
|
||||
case scheme
|
||||
when "Basic"
|
||||
# raise ArgumentError, "provide uri for Basic authentication" unless uri
|
||||
Mechanize::HTTP::AuthRealm.new scheme, target_uri, self["realm"]
|
||||
AuthRealm.new scheme, target_uri, self["realm"]
|
||||
when "Digest"
|
||||
Mechanize::HTTP::AuthRealm.new scheme, target_uri, self["realm"]
|
||||
AuthRealm.new scheme, target_uri, self["realm"]
|
||||
else
|
||||
# raise Mechanize::Error, "unknown HTTP authentication scheme #{scheme}"
|
||||
raise Exception.new("unknown HTTP authentication scheme #{scheme}")
|
||||
|
@ -46,7 +46,7 @@ class Mechanize
|
|||
##
|
||||
# The name of the realm for this challenge
|
||||
|
||||
def realm_name
|
||||
def realm_name : String?
|
||||
params_value = params
|
||||
if params_value.is_a?(Hash)
|
||||
params_value["realm"] # NTLM has a string for params
|
||||
|
|
|
@ -10,18 +10,10 @@ class Mechanize::HTTP::AuthRealm
|
|||
@realm = realm if realm
|
||||
end
|
||||
|
||||
def ==(other)
|
||||
def ==(other) : Bool
|
||||
self.class === other &&
|
||||
@scheme == other.scheme &&
|
||||
@uri == other.uri &&
|
||||
@realm == other.realm
|
||||
end
|
||||
|
||||
def hash # :nodoc:
|
||||
[@scheme, @uri, @realm].hash
|
||||
end
|
||||
|
||||
def inspect # :nodoc:
|
||||
"#<AuthRealm %s %p \"%s\">" % [@scheme, @uri, @realm]
|
||||
end
|
||||
end
|
||||
|
|
|
@ -32,7 +32,7 @@ class Mechanize
|
|||
# Returns true if credentials exist for the +challenges+ from the server at
|
||||
# +uri+.
|
||||
|
||||
def credentials?(uri, challenges)
|
||||
def credentials?(uri, challenges) : Bool
|
||||
challenges.any? do |challenge|
|
||||
credentials_for uri, challenge.realm_name
|
||||
end
|
||||
|
|
|
@ -17,14 +17,14 @@ class Mechanize
|
|||
|
||||
# Parsers the header. Returns an Array of challenges as strings
|
||||
|
||||
def parse(www_authenticate : String)
|
||||
challenges = [] of Mechanize::HTTP::AuthChallenge
|
||||
def parse(www_authenticate : String) : Array(AuthChallenge)
|
||||
challenges = [] of AuthChallenge
|
||||
@scanner = StringScanner.new(www_authenticate)
|
||||
|
||||
loop do
|
||||
break if scanner.eos?
|
||||
start = scanner.offset
|
||||
challenge = Mechanize::HTTP::AuthChallenge.new
|
||||
challenge = AuthChallenge.new
|
||||
|
||||
scheme = auth_scheme
|
||||
|
||||
|
@ -86,7 +86,7 @@ class Mechanize
|
|||
# scans a comma followed by spaces
|
||||
# needed for Negotiation, NTLM
|
||||
|
||||
def scan_comma_spaces
|
||||
private def scan_comma_spaces
|
||||
scanner.scan(/, +/)
|
||||
end
|
||||
|
||||
|
@ -98,7 +98,7 @@ class Mechanize
|
|||
scanner.scan(/[^\000-\037\177()<>@,;:\\"\/\[\]?={} ]+/)
|
||||
end
|
||||
|
||||
def auth_scheme
|
||||
private def auth_scheme
|
||||
token
|
||||
end
|
||||
|
||||
|
@ -107,7 +107,7 @@ class Mechanize
|
|||
#
|
||||
# Parses spaces
|
||||
|
||||
def spaces
|
||||
private def spaces
|
||||
scanner.scan(/ +/)
|
||||
end
|
||||
|
||||
|
@ -137,7 +137,7 @@ class Mechanize
|
|||
#
|
||||
# For TEXT, the rules of RFC 2047 are ignored.
|
||||
|
||||
def quoted_string
|
||||
def quoted_string : String?
|
||||
return nil unless @scanner.scan(/"/)
|
||||
|
||||
text = String.new
|
||||
|
|
Loading…
Reference in New Issue