From 495c3d500640ce39d53292fd9846a2354d203675 Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Sun, 23 Oct 2011 11:15:42 -0400 Subject: [PATCH] Use new authentication style in models :metal: --- requests/models.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/requests/models.py b/requests/models.py index 852dbbda..cb10175c 100644 --- a/requests/models.py +++ b/requests/models.py @@ -94,7 +94,9 @@ class Request(object): #: content and metadata of HTTP Response, once :attr:`sent `. self.response = Response() - # if isinstance(auth, (list, tuple)): + if isinstance(auth, (list, tuple)): + from .auth import http_basic + auth = (http_basic, auth) # auth = AuthObject(*auth) # if not auth: # auth = auth_manager.get_auth(self.url) @@ -138,7 +140,7 @@ class Request(object): if self.cookies is not None: _handlers.append(urllib2.HTTPCookieProcessor(self.cookies)) - # if self.auth: + # if not isinstance(self.auth.handler, # (urllib2.AbstractBasicAuthHandler, # urllib2.AbstractDigestAuthHandler)): @@ -348,6 +350,13 @@ class Request(object): data = self._enc_data headers = {} + if self.auth: + auth_func, auth_args = self.auth + + r = auth_func(self, *auth_args) + + self.__dict__.update(r.__dict__) + # Build the Urllib2 Request. req = _Request(url, data=data, headers=headers, method=self.method)