Remove AuthObject entirely.
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Kenneth Reitz · committed by Kenneth Reitz · parent 4892a30 · Browse files · 1 file·+3 added−56 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
1 file+3 added−56 removed
- other:+3 added−56 removed
Provenance
- Commit
20e0ee4- Tree
26d0899- Author
Kenneth Reitz <me@kennethreitz.com>- Committer
Kenneth Reitz <me@kennethreitz.com>- Parent
4892a30
1 file changed+3 added−56 removed
modified:requests/models.py+3 added-56 removed
25 unmodified lines26 from .monkeys import (27 HTTPBasicAuthHandler, HTTPForcedBasicAuthHandler,28 HTTPDigestAuthHandler, HTTPRedirectHandler)29 30+from .auth import dispatch as auth_dispatch31 32 REDIRECT_STATI = (codes.moved, codes.found, codes.other, codes.temporary_moved)33 34 59 unmodified lines94 #: :class:`Response <Response>` instance, containing95 #: content and metadata of HTTP Response, once :attr:`sent <send>`.96 self.response = Response()97 97- if isinstance(auth, (list, tuple)):98- from .auth import http_basic99- auth = (http_basic, auth)100- # auth = AuthObject(*auth)101- # if not auth:102- # auth = auth_manager.get_auth(self.url)98+ #: Authentication tuple to attach to :class:`Request <Request>`.99+ self.auth = auth_dispatch(auth)100 104- #: :class:`AuthObject` to attach to :class:`Request <Request>`.105- self.auth = auth106-101 #: CookieJar to attach to :class:`Request <Request>`.102 self.cookies = cookies103 104 #: Dictionary of configurations for this request.28 unmodified lines133 134 if self.cookies is not None:135 _handlers.append(urllib2.HTTPCookieProcessor(self.cookies))136 143-144- # if not isinstance(self.auth.handler,145- # (urllib2.AbstractBasicAuthHandler,146- # urllib2.AbstractDigestAuthHandler)):147-148- # TODO: REMOVE THIS COMPLETELY149- # auth_manager.add_password(150- # self.auth.realm, self.url,151- # self.auth.username,152- # self.auth.password)153-154- # self.auth.handler = self.auth.handler(auth_manager)155- # auth_manager.add_auth(self.url, self.auth)156-157- # _handlers.append(self.auth.handler)158-137 if self.proxies:138 _handlers.append(urllib2.ProxyHandler(self.proxies))139 140 _handlers.append(HTTPRedirectHandler)365 unmodified lines506 """Raises stored :class:`HTTPError` or :class:`URLError`, if one occurred."""507 if self.error:508 raise self.error509 532-533-534-class AuthObject(object):535- """The :class:`AuthObject` is a simple HTTP Authentication token. When536- given to a Requests function, it enables Basic HTTP Authentication for that537- Request. You can also enable Authorization for domain realms with AutoAuth.538- See AutoAuth for more details.539-540- :param username: Username to authenticate with.541- :param password: Password for given username.542- :param realm: (optional) the realm this auth applies to543- :param handler: (optional) basic || digest || proxy_basic || proxy_digest544- """545-546- _handlers = {547- 'basic': HTTPBasicAuthHandler,548- 'forced_basic': HTTPForcedBasicAuthHandler,549- 'digest': HTTPDigestAuthHandler,550- 'proxy_basic': urllib2.ProxyBasicAuthHandler,551- 'proxy_digest': urllib2.ProxyDigestAuthHandler552- }553-554- def __init__(self, username, password, handler='forced_basic', realm=None):555- self.username = username556- self.password = password557- self.realm = realm558-559- if isinstance(handler, basestring):560- self.handler = self._handlers.get(handler.lower(), HTTPForcedBasicAuthHandler)561- else:562- self.handler = handler