관리-도구
편집 파일: models.cpython-310.pyc
o ƚRel� � @ 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}|r"|�d� |�|� d�|�S )zBuild the path URL to use.�/�?� )r) �url�path�append�query�join)�selfr8 �pr9 r; � r? ��/builddir/build/BUILDROOT/alt-python310-pip-21.3.1-3.el8.x86_64/opt/alt/python310/lib/python3.10/site-packages/pip/_vendor/requests/models.py�path_url= s zRequestEncodingMixin.path_urlc C s� t | ttf�r | S t| d�r| S t| d�rWg }t| �D ]5\}}t |t�s)t|d�s,|g}|D ]!}|durO|�t |t�r@|�d�n|t |t�rK|�d�n|f� q.qt|dd�S | S )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__N�utf-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��t|t�rt d��g }t|pi �}t| pi �} |D ]>\}}t|t�s-t|d�s0|g}|D ]*}|dur\t|t�sAt|�}|�t|t�rM|�d�n|t|t�rX|� d�n|f� q2q| D ]d\}}d}d} t|t tf�r�t|�dkrz|\} }nt|�dkr�|\} }}n|\} }}} nt |�p�|} |}t|tttf�r�|}nt|d�r�|�� }n|du r�q`|}t||| | d �} | j|d � |�| � q`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 NrD � � rB )�namerI �filename�headers)�content_type)� ValueErrorrF r0 r rG r, r+ r: �decoderH �tuple�list�lenr � bytearrayrB r �make_multipartr )�filesrI � new_fields�fields�field�valrM rK �ft�fh�fn�fp�fdata�rf�bodyrT r? r? r@ � _encode_filesm sX ���� z"RequestEncodingMixin._encode_filesN)�__name__� __module__�__qualname__�propertyrA �staticmethodrN rh r? r? r? r@ r4 <