def update_from_challenge!(options)
@h[:username] = options[:username]
@h[:password] = options[:password]
@h[:digest] = options[:digest]
@h[:uri] = options[:uri]
@h[:method] = options[:method]
@h[:request_body] = options[:request_body]
unless @h[:qop].nil?
if !options[:qop].nil? and @h[:qop].include?(options[:qop])
@h[:qop] = options[:qop]
elsif @h[:qop].include?(HTTPAuth::PREFERRED_QOP)
@h[:qop] = HTTPAuth::PREFERRED_QOP
else
qop = @h[:qop].detect { |qop| HTTPAuth::SUPPORTED_QOPS.include? qop }
unless qop.nil?
@h[:qop] = qop
else
raise UnsupportedError.new("HTTPAuth doesn't support any of the proposed qop values: #{@h[:qop].inspect}")
end
end
@h[:cnonce] ||= Utils.create_nonce options[:salt]
@h[:nc] ||= 1 unless @h[:qop].nil?
end
@h[:response] = Utils.calculate_digest(@h, @s, :request)
end