'Handles API requests.'

def _HandleApi(self, request):

    ValidateCSRFTokenOrRaise(request)
    response = http_api.RenderHttpResponse(request)
    if (('csrftoken' not in request.cookies) or (response.headers.get('X-API-Method', '') == 'GetPendingUserNotificationsCount')):
        StoreCSRFCookie(request.user, response)
    return response
