def send(self, anyway=False, prefetch=False):
        """Sends the request. Returns True of successful, false if not.
        If there was an HTTPError during transmission,
        self.response.status_code will contain the HTTPError code.

        Once a request is successfully sent, `sent` will equal True.

        :param anyway: If True, request will be sent, even if it has
        already been sent.
        """

        # Logging
        if self.config.get('verbose'):
            self.config.get('verbose').write('%s   %s   %s\n' % (
                datetime.now().isoformat(), self.method, self.url
            ))

        # Build the URL
        url = self.full_url

        # Nottin' on you.
        body = None
        content_type = None

        # Multi-part file uploads.
        if self.files:
            if not isinstance(self.data, basestring):

                try:
                    fields = self.data.copy()
                except AttributeError:
                    fields = dict(self.data)

                for (k, v) in self.files.items():
                    fields.update({k: (guess_filename(k) or k, v.read())})

                (body, content_type) = encode_multipart_formdata(fields)
            else:
                pass
                # TODO: Conflict?
        else:
            if self.data:

                body = self._enc_data
                if isinstance(self.data, basestring):
                    content_type = None
                else:
                    content_type = 'application/x-www-form-urlencoded'

        # Add content-type if it wasn't explicitly provided.
        if (content_type) and (not 'content-type' in self.headers):
            self.headers['Content-Type'] = content_type


        if self.auth:
            auth_func, auth_args = self.auth

            # Allow auth to make its changes.
            r = auth_func(self, *auth_args)

            # Update self to reflect the auth changes.
            self.__dict__.update(r.__dict__)

        _p = urlparse(url)
        proxy = self.proxies.get(_p.scheme)

        if proxy:
            conn = poolmanager.proxy_from_url(proxy)
        else:
            # Check to see if keep_alive is allowed.
            if self.config.get('keep_alive'):
                conn = self._poolmanager.connection_from_url(url)
            else:
                conn = connectionpool.connection_from_url(url)

        if not self.sent or anyway:

            if self.cookies:

                # Skip if 'cookie' header is explicitly set.
                if 'cookie' not in self.headers:

                    # Simple cookie with our dict.
                    c = SimpleCookie()
                    for (k, v) in self.cookies.items():
                        c[k] = v

                    # Turn it into a header.
                    cookie_header = c.output(header='').strip()

                    # Attach Cookie header to request.
                    self.headers['Cookie'] = cookie_header

            try:
                # Send the request.
                r = conn.urlopen(
                    method=self.method,
                    url=self.path_url,
                    body=body,
                    headers=self.headers,
                    redirect=False,
                    assert_same_host=False,
                    preload_content=prefetch,
                    decode_content=False,
                    retries=self.config.get('max_retries', 0),
                    timeout=self.timeout,
                )


            except MaxRetryError, e:
                if not self.config.get('safe_mode', False):
                    raise ConnectionError(e)
                else:
                    r = None

            except (_SSLError, _HTTPError), e:
                if not self.config.get('safe_mode', False):
                    raise Timeout('Request timed out.')

            self._build_response(r)

            # Response manipulation hook.
            self.response = dispatch_hook('response', self.hooks, self.response)

            # Post-request hook.
            r = dispatch_hook('post_request', self.hooks, self)
            self.__dict__.update(r.__dict__)

            # If prefetch is True, mark content as consumed.
            if prefetch:
                self.response._content_consumed = True

            return self.sent
def send ( self , anyway = False , prefetch = False ) : if self . config . get ( 'verbose' ) : self . config . get ( 'verbose' ) . write ( '%s   %s   %s\n' % ( datetime . now ( ) . isoformat ( ) , self . method , self . url ) ) url = self . full_url body = None content_type = None if self . files : if not isinstance ( self . data , basestring ) : try : fields = self . data . copy ( ) except AttributeError : fields = dict ( self . data ) for ( k , v ) in self . files . items ( ) : fields . update ( { k : ( guess_filename ( k ) or k , v . read ( ) ) } ) ( body , content_type ) = encode_multipart_formdata ( fields ) else : pass else : if self . data : body = self . _enc_data if isinstance ( self . data , basestring ) : content_type = None else : content_type = 'application/x-www-form-urlencoded' if ( content_type ) and ( not 'content-type' in self . headers ) : self . headers [ 'Content-Type' ] = content_type if self . auth : auth_func , auth_args = self . auth r = auth_func ( self , * auth_args ) self . __dict__ . update ( r . __dict__ ) _p = urlparse ( url ) proxy = self . proxies . get ( _p . scheme ) if proxy : conn = poolmanager . proxy_from_url ( proxy ) else : if self . config . get ( 'keep_alive' ) : conn = self . _poolmanager . connection_from_url ( url ) else : conn = connectionpool . connection_from_url ( url ) if not self . sent or anyway : if self . cookies : if 'cookie' not in self . headers : c = SimpleCookie ( ) for ( k , v ) in self . cookies . items ( ) : c [ k ] = v cookie_header = c . output ( header = '' ) . strip ( ) self . headers [ 'Cookie' ] = cookie_header try : r = conn . urlopen ( method = self . method , url = self . path_url , body = body , headers = self . headers , redirect = False , assert_same_host = False , preload_content = prefetch , decode_content = False , retries = self . config . get ( 'max_retries' , 0 ) , timeout = self . timeout , ) except MaxRetryError , e : if not self . config . get ( 'safe_mode' , False ) : raise ConnectionError ( e ) else : r = None except ( _SSLError , _HTTPError ) , e : if not self . config . get ( 'safe_mode' , False ) : raise Timeout ( 'Request timed out.' ) self . _build_response ( r ) self . response = dispatch_hook ( 'response' , self . hooks , self . response ) r = dispatch_hook ( 'post_request' , self . hooks , self ) self . __dict__ . update ( r . __dict__ ) if prefetch : self . response . _content_consumed = True return self . sent
Sends the request. Returns True of successful, false if not.
        If there was an HTTPError during transmission,
        self.response.status_code will contain the HTTPError code.

        Once a request is successfully sent, `sent` will equal True.

        :param anyway: If True, request will be sent, even if it has
        already been sent.