Skip to content
Myr

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

1 file+3 added−56 removed

modified:requests/models.py+3 added-56 removed
25 unmodified lines
26from .monkeys import (27 HTTPBasicAuthHandler, HTTPForcedBasicAuthHandler,28 HTTPDigestAuthHandler, HTTPRedirectHandler)2930from .auth import dispatch as auth_dispatch3132REDIRECT_STATI = (codes.moved, codes.found, codes.other, codes.temporary_moved)3334
59 unmodified lines
94 #: :class:`Response <Response>` instance, containing95 #: content and metadata of HTTP Response, once :attr:`sent <send>`.96 self.response = Response()9797 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)100104 #: :class:`AuthObject` to attach to :class:`Request <Request>`.105 self.auth = auth106101 #: CookieJar to attach to :class:`Request <Request>`.102 self.cookies = cookies103104 #: Dictionary of configurations for this request.
28 unmodified lines
133134 if self.cookies is not None:135 _handlers.append(urllib2.HTTPCookieProcessor(self.cookies))136143144 # if not isinstance(self.auth.handler,145 # (urllib2.AbstractBasicAuthHandler,146 # urllib2.AbstractDigestAuthHandler)):147148 # TODO: REMOVE THIS COMPLETELY149 # auth_manager.add_password(150 # self.auth.realm, self.url,151 # self.auth.username,152 # self.auth.password)153154 # self.auth.handler = self.auth.handler(auth_manager)155 # auth_manager.add_auth(self.url, self.auth)156157 # _handlers.append(self.auth.handler)158137 if self.proxies:138 _handlers.append(urllib2.ProxyHandler(self.proxies))139140 _handlers.append(HTTPRedirectHandler)
365 unmodified lines
506 """Raises stored :class:`HTTPError` or :class:`URLError`, if one occurred."""507 if self.error:508 raise self.error509532533534class 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.539540 :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 """545546 _handlers = {547 'basic': HTTPBasicAuthHandler,548 'forced_basic': HTTPForcedBasicAuthHandler,549 'digest': HTTPDigestAuthHandler,550 'proxy_basic': urllib2.ProxyBasicAuthHandler,551 'proxy_digest': urllib2.ProxyDigestAuthHandler552 }553554 def __init__(self, username, password, handler='forced_basic', realm=None):555 self.username = username556 self.password = password557 self.realm = realm558559 if isinstance(handler, basestring):560 self.handler = self._handlers.get(handler.lower(), HTTPForcedBasicAuthHandler)561 else:562 self.handler = handler