�
ӵ Yc @ sb d Z d d l m Z m Z d d l m Z m Z d e f d � � YZ d e f d � � YZ d S( s�
requests_toolbelt.auth.handler
==============================
This holds all of the implementation details of the Authentication Handler.
i����( t AuthBaset
HTTPBasicAuth( t urlparset
urlunparset AuthHandlerc B s\ e Z d Z d � Z d � Z d � Z d � Z e d � � Z d � Z d � Z
d � Z RS( s�
The ``AuthHandler`` object takes a dictionary of domains paired with
authentication strategies and will use this to determine which credentials
to use when making a request. For example, you could do the following:
.. code-block:: python
from requests import HTTPDigestAuth
from requests_toolbelt.auth.handler import AuthHandler
import requests
auth = AuthHandler({
'https://api.github.com': ('sigmavirus24', 'fakepassword'),
'https://example.com': HTTPDigestAuth('username', 'password')
})
r = requests.get('https://api.github.com/user', auth=auth)
# => <Response [200]>
r = requests.get('https://example.com/some/path', auth=auth)
# => <Response [200]>
s = requests.Session()
s.auth = auth
r = s.get('https://api.github.com/user')
# => <Response [200]>
.. warning::
:class:`requests.auth.HTTPDigestAuth` is not yet thread-safe. If you
use :class:`AuthHandler` across multiple threads you should
instantiate a new AuthHandler for each thread with a new
HTTPDigestAuth instance for each thread.
c C s t | � | _ | j � d S( N( t dictt
strategiest
_make_uniform( t selfR ( ( sB /usr/lib/python2.7/site-packages/requests_toolbelt/auth/handler.pyt __init__6 s c C s | j | j � } | | � S( N( t get_strategy_fort url( R t requestt auth( ( sB /usr/lib/python2.7/site-packages/requests_toolbelt/auth/handler.pyt __call__: s c C s d j | j � S( Ns <AuthHandler({0!r})>( t formatR ( R ( ( sB /usr/lib/python2.7/site-packages/requests_toolbelt/auth/handler.pyt __repr__>