Skip to content

Commit

Permalink
Use new authentication style in models
Browse files Browse the repository at this point in the history
🤘
  • Loading branch information
Kenneth Reitz committed Oct 23, 2011
1 parent 06a5aed commit 495c3d5
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions requests/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,9 @@ def __init__(self,
#: content and metadata of HTTP Response, once :attr:`sent <send>`.
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)
Expand Down Expand Up @@ -138,7 +140,7 @@ def _get_opener(self):
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)):
Expand Down Expand Up @@ -348,6 +350,13 @@ def send(self, anyway=False):
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)

Expand Down

0 comments on commit 495c3d5

Please sign in to comment.