def decode(query)
if query.nil? or query.length == 0
return nil
end
begin
message = Message.from_post_args(query)
rescue InvalidOpenIDNamespace => e
query = query.dup
query['openid.ns'] = OPENID2_NS
message = Message.from_post_args(query)
raise ProtocolError.new(message, e.to_s)
end
mode = message.get_arg(OPENID_NS, 'mode')
if !mode
msg = sprintf("No mode value in message %s", message)
raise ProtocolError.new(message, msg)
end
handler = @@handlers.fetch(mode, self.method('default_decoder'))
return handler.call(message, @server.op_endpoint)
end