Your IP : 3.137.159.163
B
^��`+� � @ s� d Z ddlZddlZddlZddlmZ ddlmZ ddl m
Z
ddlmZm
Z
mZmZ ddlmZ dd lmZ dd
lmZ ddlmZ ddlmZmZmZ dd
lmZmZmZm Z m!Z!m"Z"m#Z#m$Z$ ddl%m&Z&m'Z' ddl(m)Z)m*Z*m+Z+m,Z,m-Z-m.Z.m/Z/m0Z0m1Z1m2Z2 ddl3m4Z4m5Z5m6Z6m7Z7m8Z8m9Z9m:Z:m;Z;m<Z<m=Z=m>Z>m?Z? ddl3m@ZA ddlBmCZC eCjDeCjEeCjFeCjGeCjHfZIdZJdZKdZLG dd� deM�ZNG dd� deM�ZOG dd� deO�ZPG dd� deNeO�ZQG dd� deM�ZRdS ) z`
requests.models
~~~~~~~~~~~~~~~
This module contains the primary objects that power Requests.
� N)�RequestField)�encode_multipart_formdata)� parse_url)�DecodeError�ReadTimeoutError�
ProtocolError�LocationParseError)�UnsupportedOperation� )�
default_hooks)�CaseInsensitiveDict)�
HTTPBasicAuth)�cookiejar_from_dict�get_cookie_header�_copy_cookie_jar)� HTTPError�
MissingSchema�
InvalidURL�ChunkedEncodingError�ContentDecodingError�ConnectionError�StreamConsumedError�InvalidJSONError)�to_native_string�unicode_is_ascii)
�guess_filename�get_auth_from_url�requote_uri�stream_decode_response_unicode�to_key_val_list�parse_header_links�iter_slices�guess_json_utf� super_len�check_header_validity)�Callable�Mapping� cookielib�
urlunparse�urlsplit� urlencode�str�bytes�is_py2�chardet�builtin_str�
basestring)�json)�codes� i ( i c @ s0 e Zd Zedd� �Zedd� �Zedd� �ZdS )�RequestEncodingMixinc C sN g }t | j�}|j}|sd}|�|� |j}|rD|�d� |�|� d�|�S )zBuild the path URL to use.�/�?� )r) �url�path�append�query�join)�selfr8 �pr9 r; � r? �@/opt/alt/python37/lib/python3.7/site-packages/requests/models.py�path_url= s
zRequestEncodingMixin.path_urlc C s� t | ttf�r| S t| d�r | S t| d�r�g }xzt| �D ]n\}}t |t�sTt|d�sZ|g}xJ|D ]B}|dk r`|�t |t�r�|�d�n|t |t�r�|�d�n|f� q`W q8W t|dd�S | S dS )z�Encode parameters in a piece of data.
Will successfully encode parameters when passed as a dict or a list of
2-tuples. Order is retained if data is a list of 2-tuples but arbitrary
if parameters are supplied as a dict.
�read�__iter__Nzutf-8T)�doseq) �
isinstancer+ r, �hasattrr r0 r: �encoder* )�data�result�k�vs�vr? r? r@ �_encode_paramsR s
$z#RequestEncodingMixin._encode_paramsc C s� | st d��nt|t�r t d��g }t|p,i �}t| p8i �} x�|D ]�\}}t|t�s^t|d�sd|g}x\|D ]T}|dk rjt|t�s�t|�}|�t|t�r�|�d�n|t|t�r�|� d�n|f� qjW qBW x�| D ]�\}}d}d} t|t
tf��r,t|�dk�r|\}
}n&t|�dk�r|\}
}}n|\}
}}} nt
|��p8|}
|}t|tttf��rV|}n(t|d��rl|�� }n|dk�rzq�n|}t|||
| d �}
|
j|d
� |�|
� q�W t|�\}}||fS )a� Build the body for a multipart/form-data request.
Will successfully encode files when passed as a dict or a list of
tuples. Order is retained if data is a list of tuples but arbitrary
if parameters are supplied as a dict.
The tuples may be 2-tuples (filename, fileobj), 3-tuples (filename, fileobj, contentype)
or 4-tuples (filename, fileobj, contentype, custom_headers).
zFiles must be provided.zData must not be a string.rC Nzutf-8� � rB )�namerH �filename�headers)�content_type)�
ValueErrorrE r0 r rF r, r+ r: �decoderG �tuple�list�lenr � bytearrayrB r Zmake_multipartr )�filesrH Z
new_fields�fields�field�valrL rJ ZftZfh�fn�fpZfdataZrf�bodyrS r? r? r@ �
_encode_filesm sP
$
z"RequestEncodingMixin._encode_filesN)�__name__�
__module__�__qualname__�propertyrA �staticmethodrM ra r? r? r? r@ r4 <