def request(self, method, url, headers=None, body=None):
        """Make a new HTTP request.

        The *method* argument is the HTTP method as a string, for example
        ``'GET'`` or ``'POST'``. The *url* argument specifies the URL.

        The optional *headers* argument specifies extra HTTP headers to use in
        the request. It must be a sequence of ``(name, value)`` tuples.

        The optional *body* argument may be used to include a body in the
        request. It must be a ``bytes`` instance, a file-like object opened in
        binary mode, or an iterable producing ``bytes`` instances.  To send
        potentially large bodies, use the file or iterator interfaces. This has
        the benefit that only a single chunk is kept in memory at a time.

        The response to the request can be obtained by calling the
        :meth:`getresponse` method. You may make multiple requests before
        reading a response. For every request that you make however, you must
        call :meth:`getresponse` exactly once. The remote HTTP implementation
        will send by the responses in the same order as the requests.

        This method will use the "chunked" transfer encoding if here is a body
        and the body size is unknown ahead of time. This happens when the file
        or interator interface is used in the abence of a "Content-Length"
        header.
        """
        if self._error:
            raise compat.saved_exc(self._error)
        elif self._transport is None:
            raise HttpError('not connected')
        request = HttpRequest(self)
        bodylen = -1 if body is None else \
                        len(body) if isinstance(body, bytes) else None
        request.start_request(method, url, headers, bodylen)
        if isinstance(body, bytes):
            request.write(body)
        elif hasattr(body, 'read'):
            while True:
                chunk = body.read(4096)
                if not chunk:
                    break
                request.write(chunk)
        elif hasattr(body, '__iter__'):
            for chunk in body:
                request.write(chunk)
        request.end_request()
def request ( self , method , url , headers = None , body = None ) : if self . _error : raise compat . saved_exc ( self . _error ) elif self . _transport is None : raise HttpError ( 'not connected' ) request = HttpRequest ( self ) bodylen = - 1 if body is None else len ( body ) if isinstance ( body , bytes ) else None request . start_request ( method , url , headers , bodylen ) if isinstance ( body , bytes ) : request . write ( body ) elif hasattr ( body , 'read' ) : while True : chunk = body . read ( 4096 ) if not chunk : break request . write ( chunk ) elif hasattr ( body , '__iter__' ) : for chunk in body : request . write ( chunk ) request . end_request ( )
Make a new HTTP request.

        The *method* argument is the HTTP method as a string, for example
        ``'GET'`` or ``'POST'``. The *url* argument specifies the URL.

        The optional *headers* argument specifies extra HTTP headers to use in
        the request. It must be a sequence of ``(name, value)`` tuples.

        The optional *body* argument may be used to include a body in the
        request. It must be a ``bytes`` instance, a file-like object opened in
        binary mode, or an iterable producing ``bytes`` instances.  To send
        potentially large bodies, use the file or iterator interfaces. This has
        the benefit that only a single chunk is kept in memory at a time.

        The response to the request can be obtained by calling the
        :meth:`getresponse` method. You may make multiple requests before
        reading a response. For every request that you make however, you must
        call :meth:`getresponse` exactly once. The remote HTTP implementation
        will send by the responses in the same order as the requests.

        This method will use the "chunked" transfer encoding if here is a body
        and the body size is unknown ahead of time. This happens when the file
        or interator interface is used in the abence of a "Content-Length"
        header.