관리-도구
편집 파일: client.cpython-311.pyc
� �܋f� � � � d Z ddlmZmZmZmZ ddlmZmZm Z m Z ddlmZ ddl mZ ddl mZ ddlmZ ddlZddlZddlZdd lmZ ddlZdd lmZ erddlmZ nddlmZ g d�Zd Z dZ!dZ"dZ#dZ$dZ%dZ&dZ'dZ(dZ)dZ*dZ+dZ,dZ-dZ.dZ/dZ0dZ1dZ2d Z3d!Z4d"Z5d#Z6d$Z7d%Z8d&Z9d'Z:d(Z;d)Z<d*Z=d+Z>d,Z?d-Z@d.ZAd/ZBd0ZCd1ZDd2ZEd3ZFd4ZGd5ZHd6ZId7ZJd8ZKd9ZLd:ZMd;ZNd<ZOd=ZPd>ZQd?ZRd@ZSdAZTdBZUdCZVdDZWdEZXdFZYdGZZi ddH�ddI�ddJ�ddK�ddL�ddM�ddN�ddO�ddP�ddQ�d dR�d!dS�d"dT�d#dU�d$dV�dWdX�d%dY�i d&dZ�d'd[�d(d\�d)d]�d*d^�d+d_�d,d`�d-da�d.db�d/dc�d0dd�d1de�d2df�d3dg�d4dh�d5di�d6dj��dkdldmdndodpdqdrdsdtdudv��Z[dwZ\dxZ]dZ^ G dy� dzej_ � � Z`e`fd{�Za eb� � Zc G d|� d}ejd � � Ze G d~� deb� � Zf ddlgZgdd�lgmhZh G d�� d�ef� � Zie�j d�� � n# ek$ r Y nw xY w G d�� d�el� � Zm G d�� d�em� � Zn G d�� d�em� � Zo G d�� d�em� � Zp G d�� d�em� � Zq G d�� d�em� � Zr G d�� d�em� � Zs G d�� d�em� � Zt G d�� d�et� � Zu G d�� d�et� � Zv G d�� d�et� � Zw G d�� d�em� � Zx G d�� d�em� � ZyemZzdS )�aD HTTP/1.1 client library A backport of the Python 3.3 http/client.py module for python-future. <intro stuff goes here> <other stuff, too> HTTPConnection goes through a number of "states", which define when a client may legally make another request or fetch the response for a particular request. This diagram details these state transitions: (null) | | HTTPConnection() v Idle | | putrequest() v Request-started | | ( putheader() )* endheaders() v Request-sent | | response = getresponse() v Unread-response [Response-headers-read] |\____________________ | | | response.read() | putrequest() v v Idle Req-started-unread-response ______/| / | response.read() | | ( putheader() )* endheaders() v v Request-started Req-sent-unread-response | | response.read() v Request-sent This diagram presents the following rules: -- a second request may not be started until {response-headers-read} -- a response [object] cannot be retrieved until {request-sent} -- there is no differentiation between an unread response body and a partially read response body Note: this enforcement is applied by the HTTPConnection class. The HTTPResponse class does not enforce this state machine, which implies sophisticated clients may accelerate the request/response pipeline. Caution should be taken, though: accelerating the states beyond the above pattern may imply knowledge of the server's connection-close behavior for certain requests. For example, it is impossible to tell whether the server will close the connection UNTIL the response headers have been read; this means that further requests cannot be placed into the pipeline until it is known that the server will NOT be closing the connection. Logical State __state __response ------------- ------- ---------- Idle _CS_IDLE None Request-started _CS_REQ_STARTED None Request-sent _CS_REQ_SENT None Unread-response _CS_IDLE <response_class> Req-started-unread-response _CS_REQ_STARTED <response_class> Req-sent-unread-response _CS_REQ_SENT <response_class> � )�absolute_import�division�print_function�unicode_literals)�bytes�int�str�super)�PY2)�parser)�message)�create_connectionN)�urlsplit)�array)�Iterable)�HTTPResponse�HTTPConnection� HTTPException�NotConnected�UnknownProtocol�UnknownTransferEncoding�UnimplementedFileMode�IncompleteRead� InvalidURL�ImproperConnectionState�CannotSendRequest�CannotSendHeader�ResponseNotReady� BadStatusLine�error� responses�P i� �UNKNOWN�IdlezRequest-startedzRequest-sent�d �e �f �� �� �� �� �� �� �� �� �� i, i- i. i/ i0 i1 i3 i� i� i� i� i� i� i� i� i� i� i� i� i� i� i� i� i� � i� i� i� i� � � � �� � � � � � i� i� � �ContinuezSwitching Protocols�OK�Created�AcceptedzNon-Authoritative Informationz No Contentz Reset ContentzPartial ContentzMultiple ChoiceszMoved Permanently�Foundz See OtherzNot Modifiedz Use Proxyi2 z(Unused)zTemporary RedirectzBad Request�UnauthorizedzPayment Required� Forbiddenz Not FoundzMethod Not AllowedzNot AcceptablezProxy Authentication RequiredzRequest Timeout�Conflict�GonezLength RequiredzPrecondition FailedzRequest Entity Too LargezRequest-URI Too LongzUnsupported Media TypezRequested Range Not SatisfiablezExpectation FailedzPrecondition RequiredzToo Many RequestszRequest Header Fields Too LargezInternal Server ErrorzNot ImplementedzBad GatewayzService UnavailablezGateway TimeoutzHTTP Version Not SupportedzNetwork Authentication Required)r1 r2 r3 r4 r5 r6 r7 r8 r9 r: r; i i c � � e Zd Zd� ZdS )�HTTPMessagec �8 � |� � � dz }t |� � }g }d}| � � � D ]Z}|d|� � � � |k rd}n|dd� � � � sd}|r|� |� � �[|S )a� Find all header lines matching a given header name. Look through the list of headers and find all lines matching a given header name (and their continuation lines). A list of the lines is returned, without interpretation. If the header does not occur, an empty list is returned. If the header occurs multiple times, all occurrences are returned. Case is not important in the header name. �:r N� )�lower�len�keys�isspace�append)�self�name�n�lst�hit�lines �m/builddir/build/BUILD/cloudlinux-venv-1.0.6/venv/lib/python3.11/site-packages/future/backports/http/client.py�getallmatchingheadersz!HTTPMessage.getallmatchingheaders� s� � � �z�z�|�|�c�!����I�I�������I�I�K�K� !� !�D��B�Q�B�x�~�~���4�'�'�����"�1�"�X�%�%�'�'� ���� !�� � �4� � � ��� � N)�__name__� __module__�__qualname__rV � rW rU rF rF � s# � � � � � �� � � � rW rF c �� � g } | � t dz � � }t |� � t k rt d� � �|� |� � t |� � t k rt dt z � � �|dv rn��t d� � � |� � � d� � }t j |�� � � |� � S ) aG Parses only RFC2822 headers from a file pointer. email Parser wants to see strings rather than bytes. But a TextIOWrapper around self.rfile would buffer too many bytes from the stream, bytes which we later need to read as bytes. So we read the correct bytes here, as bytes, for email Parser to parse. TrI �header linezgot more than %d headers�� � rW rW � iso-8859-1)�_class) �readline�_MAXLINErK �LineTooLongrN �_MAXHEADERSr r �join�decode�email_parser�Parser�parsestr)�fprb �headersrT �hstrings rU � parse_headersro s� � � �G���{�{�8�a�<�(�(���t�9�9�x����m�,�,�,����t�����w�<�<�+�%�%�� :�[� H�I�I�I��(�(�(��� �C�j�j�o�o�g�&�&�-�-�l�;�;�G���f�-�-�-�6�6�w�?�?�?rW c � � � e Zd Zdeddfd�Zd� Zd� Zd� Zd� Z� fd�Z � fd �Z d � Zd� Zd� fd� Z d � Zd� Zd� Zd� Zd� Zd� Zd� Zd� Zdd�Zd� Zd� Zd� Zd� Zd� Z� xZS )r r Nc �b � |� d� � | _ || _ |t urt j dt d� � || _ d x| _ | _ t | _ t | _ t | _ t | _ t | _ t | _ t | _ d S )N�rb�ithe 'strict' argument isn't supported anymore; http.client now always assumes HTTP/1.x compliant servers.� )�makefilerl � debuglevel�_strict_sentinel�warnings�warn�DeprecationWarning�_methodrm �msg�_UNKNOWN�version�status�reason�chunked� chunk_left�length� will_close)rO �sockrv �strict�method�urls rU �__init__zHTTPResponse.__init__* s� � � �-�-��%�%���$����)�)�)��M� M�"�A� '� '� '� ��� #'�&���t�x� ������������"������"����rW c �� � t | j � t dz � � d� � }t |� � t k rt d� � �| j dk rt dt |� � � � |st |� � � |� d d� � \ }}}n?# t $ r2 |� d d� � \ }}d}n# t $ r d}Y nw xY wY nw xY w|� d� � s#| � � � t |� � � t |� � }|d k s|d k rt |� � �n# t $ r t |� � �w xY w|||fS )NrI ra zstatus liner zreply:rt � zHTTP/r% i� )r rl rc rd rK re rv �print�reprr �split� ValueError� startswith�_close_connr )rO rT r~ r r� s rU �_read_statuszHTTPResponse._read_statusL s� � ��4�7�#�#�H�q�L�1�1�<�@�@���t�9�9�x����m�,�,�,��?�Q����(�D��J�J�'�'�'�� &� ��%�%�%� �&*�j�j��q�&9�&9�#�G�V�V�V��� � � � �"&�*�*�T�1�"5�"5��������� � � ����� ������ ���� �!�!�'�*�*� &���������%�%�%� &���[�[�F���|�|�v��|�|�#�D�)�)�)� ,��� &� &� &���%�%�%� &�������&�&sB �B- �- C)�8C�C)�C#� C)�"C#�#C)�(C)�%*E �E*c �6 � | j �d S | � � � \ }}}|t k rn~ | j � t dz � � }t |� � t k rt d� � �|� � � }|sn| j dk rt d|� � �|��|x| _ | _ |� � � | _ |dv rd| _ n,|� d� � rd | _ nt! |� � �t# | j � � x| _ | _ | j dk r| j D ]}t d|d �� � �| j � d� � }|r'|� � � d k rd| _ d | _ nd| _ | � � � | _ d | _ | j � d� � }| j � d� � }|rF| j s? t5 |� � | _ | j dk rd | _ n# t6 $ r d | _ Y nw xY wd | _ |t8 k s%|t: k sd|cxk rdk s n | j dk rd| _ | j s| j s| j � d| _ d S d S d S d S )NTrI r] r zheader:)zHTTP/1.0zHTTP/0.9� zHTTP/1.� � )�endztransfer-encodingr� F�content-lengthr% r( �HEAD)rm r� �CONTINUErl rc rd rK re �striprv r� �coder r� r~ r� r ro r| �getrJ r� r� �_check_closer� r� r r� � NO_CONTENT�NOT_MODIFIEDr{ )rO r~ r r� �skip�hdr�tr_encr� s rU �beginzHTTPResponse.beginl s� � ��<�#��F� +�&*�&7�&7�&9�&9�#�G�V�V���!�!�� +��w�'�'��1��5�5���t�9�9�x�'�'�%�m�4�4�4��z�z�|�|��� ���?�Q�&�&��)�T�*�*�*� +� +� #)�(�� �D�K��l�l�n�n����.�.�.��D�L�L� � � � � *� *� +��D�L�L�!�'�*�*�*�"/���"8�"8�8���t�x��?�Q����|� /� /���i��#�.�.�.�.�.� ��!�!�"5�6�6��� !�f�l�l�n�n� �1�1��D�L�"�D�O�O� �D�L� �+�+�-�-��� �����!�!�"2�3�3�� ��!�!�"5�6�6��� �$�,� � '�!�&�k�k��� �;��?�?�"&�D�K��� � #� #� #�"����� #���� �D�K� �j� � �F�l�$:�$:��6�����C������L�F�"�"��D�K� �� #��� #��K��"�D�O�O�O� #� #� #� #��s �;H"