3 �P\P � @ sR d Z ddlmZ ddlmZ ddlmZmZ G dd� dej�Z G dd � d e �Z d S )z-The module containing the code for GuessAuth.� )�auth)�cookies� )�_digest_auth_compat�http_proxy_digestc @ s8 e Zd ZdZdd� Zdd� Zdd� Zdd � Zd d� ZdS ) � GuessAuthz7Guesses the auth type by the WWW-Authentication header.c C s || _ || _d | _d | _d S )N)�username�passwordr �pos)�selfr r � r �/usr/lib/python3.6/guess.py�__init__ s zGuessAuth.__init__c C s� | j d k r|jjj| j � |j |jj� |jj� }t|d�sHt j � |_t j|j|j|j� |j |j� tj| j| j�| _| j|�}|jj|f|�}|jj|� ||_|S )N�_cookies)r �request�body�seek�content�raw�release_conn�copy�hasattrr �RequestsCookieJarr �extract_cookies_to_jar�prepare_cookiesr Z HTTPBasicAuthr r � connection�send�history�append)r �r�kwargs�prep�_rr r r �_handle_basic_auth_401 s z GuessAuth._handle_basic_auth_401c C sf t j| j| j�| _y| jj� W n tk r4 Y nX t| jd�rV| jjd krVd| j_| jj |f|�S )N� num_401_callsr ) �auth_compatZHTTPDigestAuthr r r �init_per_thread_state�AttributeErrorr r$ � handle_401)r r r r r r �_handle_digest_auth_401'