code: def handle(self, request):
          
          request.id = str(uuid4())
          deferred = maybeDeferred(self._validate, request)
          deferred.addCallback(self.execute)
  
          def write_response(response):
              request.setHeader("Content-Length", str(len(response)))
              request.setHeader("Content-Type", self.content_type)
              # Prevent browsers from trying to guess a different content type.
              request.setHeader("X-Content-Type-Options", "nosniff")
              request.write(response)
              request.finish()
              return response
  
          def write_error(failure):
              if failure.check(APIError):
                  status = failure.value.status
  
                  # Don't log the stack traces for 4xx responses.
                  if status < 400 or status >= 500:
                      log.err(failure)
                  else:
                      log.msg("status: %s message: %s" % (
                          status, safe_str(failure.value)))
  
                  body = failure.value.response
                  if body is None:
                      body = self.dump_error(failure.value, request)
              else:
                  # If the error is a generic one (not an APIError), log the
                  # message , but don't send it back to the client, as it could
                  # contain sensitive information. Send a generic server error
                  # message instead.
                  log.err(failure)
                  body = "Server error"
                  status = 500
              request.setResponseCode(status)
              write_response(body)
  
          deferred.addCallback(write_response)
          deferred.addErrback(write_error)
          return deferred
docs: Handle an HTTP request for executing an API call.
  
          This method authenticates the request checking its signature, and then
          calls the C{execute} method, passing it a L{Call} object set with the
          principal for the authenticated user and the generic parameters
          extracted from the request.
  
          @param request: The L{HTTPRequest} to handle.