def Send(self, request_path, payload="",
           content_type="application/octet-stream",
           timeout=None,
           **kwargs):
    """Sends an RPC and returns the response.

    Args:
      request_path: The path to send the request to, eg /api/appversion/create.
      payload: The body of the request, or None to send an empty request.
      content_type: The Content-Type header to use.
      timeout: timeout in seconds; default None i.e. no timeout.
        (Note: for large requests on OS X, the timeout doesn't work right.)
      kwargs: Any keyword arguments are converted into query string parameters.

    Returns:
      The response body, as a string.
    """
    # We get the auth domain to know if we're uploading to Google or to 
    # Appscale.
    auth_domain = ''
    if 'AUTH_DOMAIN' in os.environ:
      auth_domain = os.environ['AUTH_DOMAIN'].lower()

    old_timeout = socket.getdefaulttimeout()
    socket.setdefaulttimeout(timeout)
    try:
      tries = 0
      while True:
        tries += 1
        if auth_domain == "appscale":
          self._LoadAppScaleCookie()

        url = "%s://%s%s" % (self.scheme, self.host, request_path)
        if kwargs:


          url += "?" + urllib.urlencode(sorted(kwargs.items()))
        req = self._CreateRequest(url=url, data=payload)
        req.add_header("Content-Type", content_type)



        req.add_header("X-appcfg-api-version", "1")

        try:
          logger.debug('Sending %s request:\n%s',
                       self.scheme.upper(),
                       HttpRequestToString(req, include_data=self.debug_data))
          f = self.opener.open(req)
          response = f.read()
          f.close()

          return response
        except urllib2.HTTPError, e:
          logger.debug("Got http error, this is try #%s", tries)
        
          if tries > self.rpc_tries:
            raise AppScaleAuthenticationError("Unable to authenticate " + \
                                              "with AppScale.")

          # App Load Balancer returns HTTP 502 if invalid cookie 
          # is used for authentication, though ideally it should throw 
          # HTTP 401 only. But handling HTTP 502 here until the App 
          # Load Balancer code is fixed.
          if e.code == 401 or e.code == 502:
            if auth_domain == 'appscale':
              self._AppScaleAuthenticate()
            else:
              self._Authenticate()
          elif e.code >= 500 and e.code < 600:
            continue

          elif e.code == 302:
            if tries >= 2:
              if auth_domain == 'appscale':
                logger.info("Deleting authentication cookie : %s" % \
                            self.cookie_jar.filename)
                if os.path.isfile(self.cookie_jar.filename):
                  os.remove(self.cookie_jar.filename)
                raise AppScaleAuthenticationError("Could not " + \
                      "authenticate with AppScale. Wrong username/password.")
              else:
                raise
            loc = e.info()["location"]
            logger.debug("Got 302 redirect. Location: %s", loc)
            if loc.startswith("https://www.google.com/accounts/ServiceLogin"):
              self._Authenticate()
            elif re.match(r"https://www.google.com/a/[a-z0-9.-]+/ServiceLogin",
                          loc):
              self.account_type = os.getenv("APPENGINE_RPC_HOSTED_LOGIN_TYPE",
                                            "HOSTED")
              self._Authenticate()
            elif auth_domain == 'appscale':
              loc = urlparse.urlparse(loc)
              self.scheme = loc.scheme
              self.host = loc.netloc
              self._AppScaleAuthenticate()
            elif loc.startswith((self.host,) % "http://%s/_ah/login"):
              self._DevAppServerAuthenticate()
            else:
              raise
          elif e.code == 403:
            if auth_domain == 'appscale':
              logger.info("Deleting authentication cookie : %s" % \
                          self.cookie_jar.filename)
              os.remove(self.cookie_jar.filename)
              raise AppScaleAuthenticationError("Could not authenticate " + \
                                                 "with AppScale.")
            else:
              raise
          else:
            raise
    finally:
      socket.setdefaulttimeout(old_timeout)
dataset/ETHPy150Open AppScale/appscale/AppServer/google/appengine/tools/appengine_rpc.py/AbstractRpcServer.Send/swapped operands of `%`