3 �P\8 � @ sH d Z ddlmZmZ ddlmZmZ G dd� de�ZG dd� de�ZdS ) z� requests_toolbelt.auth.handler ============================== This holds all of the implementation details of the Authentication Handler. � )�AuthBase� HTTPBasicAuth)�urlparse� urlunparsec @ sT e Zd ZdZdd� Zdd� Zdd� Zdd � Zed d� �Z dd � Z dd� Zdd� ZdS )�AuthHandlera� 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)�dict� strategies� _make_uniform)�selfr � r �/usr/lib/python3.6/handler.py�__init__6 s zAuthHandler.__init__c C s | j |j�}||�S )N)�get_strategy_for�url)r ZrequestZauthr r r �__call__: s zAuthHandler.__call__c C s dj | j�S )Nz<AuthHandler({0!r})>)�formatr )r r r r �__repr__>