def request(self, method, url, body=None, headers=None):
    """Send HTTP/HTTPS request.

    The arguments are the same as httplib.HTTPConnection.request(),
    except for the argument "body".

    Args:
      method: str, like 'GET'
      url: str, url like '/path', not like 'http://server/path'
      body: list or str or file-like obj.

        If a list, multiple items are sent in list order.

        For each item, if a str is passed, it is sent directly.  If a file
        or file-like object (implementing tell(), seek(), read()) is
        supplied, it is read from in blocks and output directly into
        the HTTP stream.  This facilitates sending large files, etc without

      headers: dict, headers to supply
    """
    # NOTE(user): if you need extreme amounts of http debugging uncomment
    # the following line:
    # self.debuglevel = 9

    if headers is None:
      headers = {}

    if body is not None:
      if type(body) is list:
        multibody = body
      else:
        multibody = [body]

      content_length = 0
      for body in multibody:
        if type(body) in self.DIRECT_SEND_TYPES:
          content_length += len(body)
        elif hasattr(body, 'tell') and hasattr(
            body, 'seek') and hasattr(body, 'read'):
          orig_pos = body.tell()
          body.seek(0, SEEK_END)
          content_length += orig_pos - body.tell()
          body.seek(orig_pos, SEEK_SET)
        else:
          raise NotImplementedError('multibody for type %s' % type(body))

      # supply this pre-calculated value to stop the parent class
      # from trying to figure it out with len().
      headers['Content-Length'] = content_length
    else:
      multibody = []
      content_length = 0

    # IMPORTANT WORKAROUND for AppEngine /_ah/upload/ service.
    #
    # Python's HTTPConnection adds a ':port' suffix to the Host header
    # when the port is not 80.  In this case we might be using
    # https so the Host header becomes "host:443".
    #
    # AppEngine 500s when it receives a Host header like
    # "APPID.appspot.com:443".
    #
    # So, we self-assign the Host header and HTTPConnection won't
    # auto-calculate it for us.
    #

    # TODO(user): This is the most conservative fix. We know that
    # AppEngine will tolerate Host: foo(noportspecified) for a https
    # tcp/443 connection.  Upon further investigation with AppEngine
    # Upload Service we could possibly refine this logic further.
    if self._is_https and self.port == 443:
      headers['Host'] = self.host

    # don't pass a body here -- let's manage sending it ourselves.
    # the connection is ready for it after this request() completes.
    # note python >=2.7 httplib now offers this functionality for us,
    # but we are continuing to do it ourselves.

    httplib.HTTPConnection.request(
        self, method, url, headers=headers)

    bytes_sent = 0
    self._ProgressCallback(bytes_sent, content_length)

    # now, send the body sections, the connection is ready.
    for body in multibody:
      if type(body) in self.DIRECT_SEND_TYPES:
        if body != '':  # sending '' blows up M2Crypto write() sometimes.
          self.send(body)
          bytes_sent += len(body)
          self._ProgressCallback(bytes_sent, content_length)
      else:
        buf = body.read(8192)
        while buf != '':
          self.send(buf)
          bytes_sent += len(buf)
          self._ProgressCallback(bytes_sent, content_length)
          buf = body.read(8192)

    self._ProgressCallback(bytes_sent, content_length)
dataset/ETHPy150Open google/simian/src/simian/client/client.py/MultiBodyConnection.request/swapped operands of `-`