(self, request, **kwargs)
return r
Send a given PreparedRequest.

        :rtype: requests.Response
Send a given PreparedRequest.
Send a given PreparedRequest .
def send(self, request, **kwargs):
        """Send a given PreparedRequest.

        :rtype: requests.Response
        """
        # Set defaults that the hooks can utilize to ensure they always have
        # the correct parameters to reproduce the previous request.
        kwargs.setdefault('stream', self.stream)
        kwargs.setdefault('verify', self.verify)
        kwargs.setdefault('cert', self.cert)
        kwargs.setdefault('proxies', self.proxies)

        # It's possible that users might accidentally send a Request object.
        # Guard against that specific failure case.
        if isinstance(request, Request):
            raise ValueError('You can only send PreparedRequests.')

        # Set up variables needed for resolve_redirects and dispatching of hooks
        allow_redirects = kwargs.pop('allow_redirects', True)
        stream = kwargs.get('stream')
        hooks = request.hooks

        # Get the appropriate adapter to use
        adapter = self.get_adapter(url=request.url)

        # Start time (approximately) of the request
        start = preferred_clock()

        # Send the request
        r = adapter.send(request, **kwargs)

        # Total elapsed time of the request (approximately)
        elapsed = preferred_clock() - start
        r.elapsed = timedelta(seconds=elapsed)

        # Response manipulation hooks
        r = dispatch_hook('response', hooks, r, **kwargs)

        # Persist cookies
        if r.history:

            # If the hooks create history then we want those cookies too
            for resp in r.history:
                extract_cookies_to_jar(self.cookies, resp.request, resp.raw)

        extract_cookies_to_jar(self.cookies, request, r.raw)

        # Redirect resolving generator.
        gen = self.resolve_redirects(r, request, **kwargs)

        # Resolve redirects if allowed.
        history = [resp for resp in gen] if allow_redirects else []

        # Shuffle things around if there's history.
        if history:
            # Insert the first (original) request at the start
            history.insert(0, r)
            # Get the last request made
            r = history.pop()
            r.history = history

        # If redirects aren't being followed, store the response on the Request for Response.next().
        if not allow_redirects:
            try:
                r._next = next(self.resolve_redirects(r, request, yield_requests=True, **kwargs))
            except StopIteration:
                pass

        if not stream:
            r.content

        return r
def send ( self , request , * * kwargs ) : # Set defaults that the hooks can utilize to ensure they always have # the correct parameters to reproduce the previous request. kwargs . setdefault ( 'stream' , self . stream ) kwargs . setdefault ( 'verify' , self . verify ) kwargs . setdefault ( 'cert' , self . cert ) kwargs . setdefault ( 'proxies' , self . proxies ) # It's possible that users might accidentally send a Request object. # Guard against that specific failure case. if isinstance ( request , Request ) : raise ValueError ( 'You can only send PreparedRequests.' ) # Set up variables needed for resolve_redirects and dispatching of hooks allow_redirects = kwargs . pop ( 'allow_redirects' , True ) stream = kwargs . get ( 'stream' ) hooks = request . hooks # Get the appropriate adapter to use adapter = self . get_adapter ( url = request . url ) # Start time (approximately) of the request start = preferred_clock ( ) # Send the request r = adapter . send ( request , * * kwargs ) # Total elapsed time of the request (approximately) elapsed = preferred_clock ( ) - start r . elapsed = timedelta ( seconds = elapsed ) # Response manipulation hooks r = dispatch_hook ( 'response' , hooks , r , * * kwargs ) # Persist cookies if r . history : # If the hooks create history then we want those cookies too for resp in r . history : extract_cookies_to_jar ( self . cookies , resp . request , resp . raw ) extract_cookies_to_jar ( self . cookies , request , r . raw ) # Redirect resolving generator. gen = self . resolve_redirects ( r , request , * * kwargs ) # Resolve redirects if allowed. history = [ resp for resp in gen ] if allow_redirects else [ ] # Shuffle things around if there's history. if history : # Insert the first (original) request at the start history . insert ( 0 , r ) # Get the last request made r = history . pop ( ) r . history = history # If redirects aren't being followed, store the response on the Request for Response.next(). if not allow_redirects : try : r . _next = next ( self . resolve_redirects ( r , request , yield_requests = True , * * kwargs ) ) except StopIteration : pass if not stream : r . content return r