lib/mechanize/http/www_authenticate_parser.rb in mechanize-2.5.1 vs lib/mechanize/http/www_authenticate_parser.rb in mechanize-2.6.0
- old
+ new
@@ -23,10 +23,11 @@
challenges = []
@scanner = StringScanner.new www_authenticate
while true do
break if @scanner.eos?
+ start = @scanner.pos
challenge = Mechanize::HTTP::AuthChallenge.new
scheme = auth_scheme
if scheme == 'Negotiate'
@@ -41,10 +42,11 @@
if scheme == 'NTLM' then
if space then
challenge.params = @scanner.scan(/.*/)
end
+ challenge.raw = www_authenticate[start, @scanner.pos]
challenges << challenge
next
else
scheme.capitalize!
end
@@ -60,21 +62,24 @@
name.downcase! if name =~ /^realm$/i
unless name then
challenge.params = params
challenges << challenge
- break if @scanner.eos?
+ if @scanner.eos? then
+ challenge.raw = www_authenticate[start, @scanner.pos]
+ break
+ end
+
@scanner.pos = pos # rewind
- challenge = '' # a token should be next, new challenge
+ challenge.raw = www_authenticate[start, @scanner.pos].sub(/(,+)? *$/, '')
+ challenge = nil # a token should be next, new challenge
break
else
params[name] = value
end
spaces
-
- return nil unless ',' == @scanner.peek(1) or @scanner.eos?
@scanner.scan(/(, *)+/)
end
end