# File lib/openid/server.rb, line 766
      def decode(query)
        return nil if query.length == 0
        
        mode = query['openid.mode']
        return nil if mode.nil?

        if mode.class == Array
          raise ArgumentError, 'query hash must have one value for each key'
        end

        case mode
        when 'checkid_setup', 'checkid_immediate'
          return CheckIDRequest.from_query(query)

        when 'check_authentication'
          return CheckAuthRequest.from_query(query)

        when 'associate'
          return AssociateRequest.from_query(query)
          
        else
          raise ProtocolError.new(query, "Unknown mode #{mode}")
        end
        
      end