gen_auth_header (WWW::Mechanize::Chain::AuthHeaders)

    # File lib/www/mechanize/chain/auth_headers.rb, line 38
            def gen_auth_header(uri, request, auth_header, is_IIS = false)
              auth_header =~ /^(\w+) (.*)/

              params = {}
              $2.gsub(/(\w+)=("[^"]*"|[^,]*)/) {
                params[$1] = $2.gsub(/^"/, '').gsub(/"$/, '')
              }

              @@nonce_count[params['nonce']] += 1

              a_1 = "#{@user}:#{params['realm']}:#{@password}"
              a_2 = "#{request.method}:#{uri.path}"
              request_digest = ''
              request_digest << Digest::MD5.hexdigest(a_1)
              request_digest << ':' << params['nonce']
              request_digest << ':' << ('%08x' % @@nonce_count[params['nonce']])
              request_digest << ':' << CNONCE
              request_digest << ':' << params['qop']
              request_digest << ':' << Digest::MD5.hexdigest(a_2)

              header = ''
              header << "Digest username=\"#{@user}\", "
              if is_IIS then
                header << "qop=\"#{params['qop']}\", "
              else
                header << "qop=#{params['qop']}, "
              end
              header << "uri=\"#{uri.path}\", "
              header << %w{ algorithm opaque nonce realm }.map { |field|
                next unless params[field]
                "#{field}=\"#{params[field]}\""
              }.compact.join(', ')

              header << "nc=#{'%08x' % @@nonce_count[params['nonce']]}, "
              header << "cnonce=\"#{CNONCE}\", "
              header << "response=\"#{Digest::MD5.hexdigest(request_digest)}\""

              return header
            end