File: //snap/core18/current/usr/lib/python3/dist-packages/requests/__pycache__/sessions.cpython-36.pyc
3
��Hh[o � @ s� d Z ddlZddlZddlZddlmZ ddlmZ ddlm Z ddl
mZmZm
Z
mZmZ ddlmZmZmZmZ dd lmZmZmZ dd
lmZmZ ddlmZ ddlmZm Z dd
l!m"Z"m#Z#m$Z$m%Z% ddl&m'Z' ddl(m)Z) ddlm*Z*m+Z+m,Z,m-Z-m.Z.m/Z/ ddl0m1Z1 ddlm2Z2 ej3� dk�rTy
ej4Z5W n e6k
�rP ej7Z5Y nX nejZ5e
fdd�Z8e
fdd�Z9G dd� de:�Z;G dd� de;�Z<dd� Z=dS )z�
requests.session
~~~~~~~~~~~~~~~~
This module provides a Session object to manage and persist settings across
requests (cookies, auth, proxies).
� N)�Mapping)� timedelta� )�_basic_auth_str)� cookielib�is_py3�OrderedDict�urljoin�urlparse)�cookiejar_from_dict�extract_cookies_to_jar�RequestsCookieJar�
merge_cookies)�Request�PreparedRequest�DEFAULT_REDIRECT_LIMIT)�
default_hooks�
dispatch_hook)�to_native_string)�to_key_val_list�default_headers)�TooManyRedirects�
InvalidSchema�ChunkedEncodingError�ContentDecodingError)�CaseInsensitiveDict)�HTTPAdapter)�requote_uri�get_environ_proxies�get_netrc_auth�should_bypass_proxies�get_auth_from_url�rewind_body)�codes)�REDIRECT_STATIZWindowsc C st |dkr| S | dkr|S t |t�o*t | t�s0| S |t|��}|jt| �� dd� |j� D �}x|D ]
}||= qbW |S )z�Determines appropriate setting for a given request, taking into account
the explicit setting on that request, and the setting in the session. If a
setting is a dictionary, they will be merged together using `dict_class`
Nc S s g | ]\}}|d kr|�qS )N� )�.0�k�vr% r% �3/usr/lib/python3/dist-packages/requests/sessions.py�
<listcomp>J s z!merge_setting.<locals>.<listcomp>)�
isinstancer r �update�items)Zrequest_settingZsession_setting�
dict_classZmerged_settingZ none_keys�keyr% r% r) �
merge_setting2 s
r0 c C s@ |dks|j d�g kr| S | dks0| j d�g kr4|S t| ||�S )z�Properly merges both requests and session hooks.
This is necessary because when request_hooks == {'response': []}, the
merge breaks Session hooks entirely.
N�response)�getr0 )Z
request_hooksZ
session_hooksr. r% r% r) �merge_hooksQ s
r3 c @ s>