code: private static boolean checkForTaskQueue(HttpServletRequest request,
        HttpServletResponse response) throws IOException {
      if (request.getHeader("X-AppEngine-QueueName") == null) {
        log.log(Level.SEVERE, "Received unexpected non-task queue request. Possible CSRF attack.");
        response.sendError(
            HttpServletResponse.SC_FORBIDDEN, "Received unexpected non-task queue request.");
        return false;
      }
      return true;
    }
docs: Checks to ensure that the current request was sent via the task queue.
  
  If the request is not in the task queue, returns false, and sets the
  response status code to 403. This protects against CSRF attacks against
  task queue-only handlers.
  
  @return true if the request is a task queue request