def _http_request(self, method, uri, headers=None, body_parts=None):
    if isinstance(uri, (str, unicode)):
      uri = Uri.parse_uri(uri)
    connection = self._get_connection(uri, headers=headers)
 
    if self.debug:
      connection.debuglevel = 1

    if connection.host != uri.host:
      connection.putrequest(method, str(uri))
    else:
      connection.putrequest(method, uri._get_relative_path())

    # Overcome a bug in Python 2.4 and 2.5
    # httplib.HTTPConnection.putrequest adding
    # HTTP request header 'Host: www.google.com:443' instead of
    # 'Host: www.google.com', and thus resulting the error message
    # 'Token invalid - AuthSub token has wrong scope' in the HTTP response.
    if (uri.scheme == 'https' and int(uri.port or 443) == 443 and
        hasattr(connection, '_buffer') and
        isinstance(connection._buffer, list)):
      header_line = 'Host: %s:443' % uri.host
      replacement_header_line = 'Host: %s' % uri.host
      try:
        connection._buffer[connection._buffer.index(header_line)] = (
            replacement_header_line)
      except ValueError:  # header_line missing from connection._buffer
        pass

    # Send the HTTP headers.
    for header_name, value in headers.iteritems():
      connection.putheader(header_name, value)
    connection.endheaders()

    # If there is data, send it in the request.
    if body_parts:
      for part in body_parts:
        _send_data_part(part, connection)
   
    # Return the HTTP Response from the server.
    return connection.getresponse()
Returns a deferred that will fire immediately if there are
dataset/ETHPy150Open CollabQ/CollabQ/vendor/atom/http_core.py/HttpClient._http_request--crossover with--dataset/ETHPy150Open flowroute/txjason/txjason/service.py/JSONRPCService.stopServing