%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3.12/http/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3.12/http/__pycache__/client.cpython-312.pyc

�

���f����b�dZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Zddlm
Z
gd�ZdZdZdZdZd	Zd
Ze�j-ej.j0�ej.j0j3�D�cic]}||j4��c}ZdZdZej<d
�j>Z ej<d�jBZ"ej<d�Z#ej<d�Z$hd�Z%d>d�Z&de'de'fd�Z(Gd�dejRjT�Z+d�Z,e+fd�Z-e+fd�Z.Gd�dej^�Z0d�Z1Gd�d�Z2	ddl3Z3Gd �d!e2�Z4ejkd!�Gd"�d#e7�Z8Gd$�d%e8�Z9Gd&�d'e8�Z:Gd(�d)e8�Z;Gd*�d+e8�Z<Gd,�d-e8�Z=Gd.�d/e8�Z>Gd0�d1e8�Z?Gd2�d3e?�Z@Gd4�d5e?�ZAGd6�d7e?�ZBGd8�d9e8�ZCGd:�d;e8�ZDGd<�d=eEeC�ZFe8ZGycc}w#e6$rY��wxYw)?a�
HTTP/1.1 client library

<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
      |\_____________________________
      |                              | getresponse() raises
      | response = getresponse()     | ConnectionError
      v                              v
    Unread-response                Idle
    [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>
�N)�urlsplit)�HTTPResponse�HTTPConnection�
HTTPException�NotConnected�UnknownProtocol�UnknownTransferEncoding�UnimplementedFileMode�IncompleteRead�
InvalidURL�ImproperConnectionState�CannotSendRequest�CannotSendHeader�ResponseNotReady�
BadStatusLine�LineTooLong�RemoteDisconnected�error�	responses�Pi��UNKNOWN�IdlezRequest-startedzRequest-senti�ds[^:\s][^:\r\n]*s\n(?![ \t])|\r(?![ \t\n])z[- ]z[-]>�PUT�POST�PATCHc
��	|jd�S#t$rl}t|j|j|j|j
|j
��d||j|j
d�d|�d��d�d}~wwxYw)z<Call data.encode("latin-1") but show a better error message.�latin-1z (z.20z) is not valid Latin-1. Use z9.encode('utf-8') if you want to send it encoded in UTF-8.N)�encode�UnicodeEncodeError�encoding�object�start�end�title)�data�name�errs   �"/usr/lib/python3.12/http/client.py�_encoder*�s}��
E��{�{�9�%�%���E� ��L�L��J�J��I�I��G�G��Z�Z�\�4��	�	�#�'�'�2�D�
:�;�AE�	E��E�s��	B�A'B�B�enc_name�returnc�n�|jd�\}}}|r|jd�sJ|��|dz
}|S)z)Remove interface scope from IPv6 address.�%�[�])�	partition�
startswith)r+�percent�_s   r)�_strip_ipv6_ifacer5�sD��#�-�-�d�3��H�g�q���"�"�4�(�2�(�2�(��D����O�c��eZdZd�Zy)�HTTPMessagec��|j�dz}t|�}g}d}|j�D]D}|d|j�|k(rd}n|ddj�sd}|s�4|j	|��F|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.

        �:rN�)�lower�len�keys�isspace�append)�selfr'�n�lst�hit�lines      r)�getallmatchingheadersz!HTTPMessage.getallmatchingheaders�s����z�z�|�c�!����I�������I�I�K�	!�D��B�Q�x�~�~��4�'����"�1�X�%�%�'�����
�
�4� �
	!��
r6N)�__name__�
__module__�__qualname__rF�r6r)r8r8�s��r6r8c���g}	|jtdz�}t|�tkDrtd��|j	|�t|�t
kDrt
dt
z��|dvr	|S�r)z�Reads potential header lines into a list from a file pointer.

    Length of line is limited by _MAXLINE, and number of
    headers is limited by _MAXHEADERS.
    r;zheader linezgot more than %d headers��
�
r6)�readline�_MAXLINEr=rr@�_MAXHEADERSr)�fp�headersrEs   r)�
_read_headersrT�st���G�
��{�{�8�a�<�(���t�9�x���m�,�,����t���w�<�+�%�� :�[� H�I�I��(�(���N�r6c��dj|�jd�}tjj	|��j|�S)aJ
    Parses only RFC2822 headers from header lines.

    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.

    r6�
iso-8859-1)�_class)�join�decode�email�parser�Parser�parsestr)�header_linesrW�hstrings   r)�_parse_header_linesr`�s@���h�h�|�$�+�+�L�9�G��<�<���f��-�6�6�w�?�?r6c�0�t|�}t||�S)z0Parses only RFC2822 headers from a file pointer.)rTr`)rRrWrSs   r)�
parse_headersrb�s���B��G��w��/�/r6c����eZdZdd�Zd�Zd�Zd�Zd�Z�fd�Z�fd�Z	d�Z
d	�Zd d
�Zd�Z
d�Zd
�Zd�Zd d�Zd�Zd�Zd�Zd!d�Zd!d�Zd!�fd�	Zd�Zd�Zd�Zd d�Zd�Zd�Zd�Zd�Zd�Z �xZ!S)"rc��|jd�|_||_||_dx|_|_t|_t|_t|_	t|_
t|_t|_t|_
y)N�rb)�makefilerR�
debuglevel�_methodrS�msg�_UNKNOWN�version�status�reason�chunked�
chunk_left�length�
will_close)rA�sockrg�method�urls     r)�__init__zHTTPResponse.__init__se���-�-��%���$������#'�&���t�x� ������������"������"��r6c�l�t|jjtdz�d�}t	|�tkDrtd��|jdkDrtdt|��|std��	|jdd�\}}}|jd	�s|j�t|��	t�}|d
ks|dkDrt|��	||fS#t$r-	|jdd�\}}d}n#t$rd}YnwxYwY��wxYw#t$rt|��wxYw)Nr;rVzstatus linerzreply:z-Remote end closed connection without response��zHTTP/ri�)�strrRrOrPr=rrg�print�reprr�split�
ValueErrorr2�_close_connr�int)rArErkrlrms     r)�_read_statuszHTTPResponse._read_status#sD���4�7�7�#�#�H�q�L�1�<�@���t�9�x���m�,�,��?�?�Q���(�D��J�'��%�&1�2�
2�	�&*�j�j��q�&9�#�G�V�V��!�!�'�*�������%�%�	&���[�F���|�v��|�#�D�)�)� ,����&�&��%�	�
�"&�*�*�T�1�"5��������
���
��		�� �	&���%�%�	&�sB�<C%�? D�%	D�/D�D�D�D�D�D�D�D3c��|j�y	|j�\}}}|tk7rn2t|j�}|j
dkDrt
d|�~�P|x|_|_|j�|_
|dvrd|_n$|jd�rd|_nt|��t|j�x|_|_|j
dkDr2|jj!�D]\}}t
d|d	z|��|jj#d
�}|r"|j%�dk(rd|_d|_nd|_|j+�|_d|_|jj#d
�}|r4|j&s(	t1|�|_|j.dkrd|_nd|_|t4k(s%|t6k(sd|cxkrdksn|j8dk(rd|_|j,s"|j&s|j.�d|_yyyy#t2$r
d|_Y�vwxYw)NTrzheaders:)zHTTP/1.0zHTTP/0.9�
zHTTP/1.��header:r:�transfer-encodingrnF�content-lengthr���HEAD)rSr��CONTINUErTrRrgrz�coderl�striprmrkr2rrbri�items�getr<rnro�_check_closerqrprr}�
NO_CONTENT�NOT_MODIFIEDrh)	rArkrlrm�skipped_headers�hdr�val�tr_encrps	         r)�beginzHTTPResponse.beginDs���<�<�#���&*�&7�&7�&9�#�G�V�V���!��+�D�G�G�4�O�����"��j�/�2���#)�(��	�D�K��l�l�n����.�.��D�L�
�
�
�	�
*��D�L�!�'�*�*�"/����"8�8���t�x��?�?�Q�� �L�L�.�.�0�
1���S��i��s��C�0�
1����!�!�"5�6���f�l�l�n�	�1��D�L�"�D�O� �D�L��+�+�-���������!�!�"2�3���$�,�,�
'�!�&�k����;�;��?�"&�D�K��D�K�
�j� �F�l�$:��6��C���L�L�F�"��D�K�
�������K�K��"�D�O�
 �� ��#�
#�"���
#�s� H2�2I�Ic�F�|jjd�}|jdk(r|rd|j�vryy|jjd�ry|rd|j�vry|jjd�}|rd|j�vryy)N�
connectionr��closeTFz
keep-alivezproxy-connection)rSr�rkr<)rA�conn�pconns   r)r�zHTTPResponse._check_close�s����|�|����-���<�<�2����4�:�:�<�/����<�<���L�)���L�D�J�J�L�0����� � �!3�4���\�U�[�[�]�2��r6c�J�|j}d|_|j�y�N)rRr�)rArRs  r)r~zHTTPResponse._close_conn�s��
�W�W�����
���
r6c���	t�|��|jr|j�yy#|jr|j�wwxYwr�)�superr�rRr~�rA�	__class__s �r)r�zHTTPResponse.close�sB���	#��G�M�O��w�w�� � �"���t�w�w�� � �"��s	�/�Ac�p��t�|��|jr|jj�yyr�)r��flushrRr�s �r)r�zHTTPResponse.flush�s%���
��
���7�7��G�G�M�M�O�r6c��y)zAlways returns TrueTrJ�rAs r)�readablezHTTPResponse.readable�s��r6c��|jduS)z!True if the connection is closed.N)rRr�s r)�isclosedzHTTPResponse.isclosed�s���w�w�$��r6c���|j�y|jdk(r|j�y|jr|j	|�S|��|j
�||j
kDr|j
}|jj
|�}|s|r|j�|S|j
�:|xj
t|�zc_|j
s|j�|S|j
�|jj
�}n#	|j|j
�}d|_|j�|S#t$r|j��wxYw)z?Read and return the response body, or up to the next amt bytes.r6r�r)
rRrhr~rn�
_read_chunkedrp�readr=�
_safe_readr)rA�amt�ss   r)r�zHTTPResponse.read�s2���7�7�?���<�<�6�!�������<�<��%�%�c�*�*��?��{�{�&�3����+<��k�k�������S�!�A���� � �"�
�H�	���(����s�1�v�%���{�{��$�$�&��H��{�{�"��G�G�L�L�N���������4�A� ��������H��&���$�$�&���s�E	�	E$c���|j�y|jdk(r|j�y|jr|j	|�S|j
�0t
|�|j
kDrt|�d|j
}|jj|�}|s|r|j�|S|j
�1|xj
|zc_|j
s|j�|S)z^Read up to len(b) bytes into bytearray b and return the number
        of bytes read.
        rr�)	rRrhr~rn�_readinto_chunkedrpr=�
memoryview�readinto)rA�brBs   r)r�zHTTPResponse.readinto�s���
�7�7�?���<�<�6�!�������<�<��)�)�!�,�,��;�;�"��1�v����#��q�M�!�D�K�K�0��

�G�G���Q����Q�
����
��	�[�[�
$��K�K�1��K��;�;�� � �"��r6c��|jjtdz�}t|�tkDrt	d��|jd�}|dk\r|d|}	t
|d�S#t$r|j��wxYw)Nr;z
chunk size�;r�)	rRrOrPr=r�findrr}r~)rArE�is   r)�_read_next_chunk_sizez"HTTPResponse._read_next_chunk_sizes����w�w����1��-���t�9�x���l�+�+��I�I�d�O����6����8�D�	��t�R�=� ���	�
�����		�s�A(�(Bc��	|jjtdz�}t|�tkDrt	d��|sy|dvry�H)Nr;ztrailer linerL)rRrOrPr=r�rArEs  r)�_read_and_discard_trailerz&HTTPResponse._read_and_discard_trailer)sO����7�7�#�#�H�q�L�1�D��4�y�8�#�!�.�1�1����,�,��r6c��|j}|sR|�|jd�	|j�}|dk(r"|j�|j
�d}||_|S#t$rt	d��wxYw)Nrwr6r)ror�r�r}rr�r~)rAros  r)�_get_chunk_leftzHTTPResponse._get_chunk_left7s����_�_�
���%�����"�
*�!�7�7�9�
��Q���.�.�0�� � �"�!�
�(�D�O�����
*�$�S�)�)�
*�s�A#�#A8c��|jtk7sJ�g}	|j�x}�s|�0||kr+|j|j	|��||z
|_nA|j|j	|��|�||z}d|_|j�x}��sdj
|�S#t$r }tdj
|��|�d}~wwxYw�Nrr6)rnrjr�r@r�rorXr)rAr��valuero�excs     r)r�zHTTPResponse._read_chunkedOs����|�|�x�'�'�'���
	;�!%�!5�!5�!7�7�:�D��?�s�j�'8��L�L�����!5�6�&0�3�&6�D�O�����T�_�_�Z�8�9��?��:�%�C�"#���"&�!5�!5�!7�7�:�D��8�8�E�?�"���	;� ����%��1�s�:��	;�s�BB/�B/�/	C�8C�Cc�f�|jtk7sJ�d}t|�}		|j�}|�|St	|�|kr |j|�}||z
|_||zS|d|}|j|�}||d}||z
}d|_�j#t$rtt|d|���wxYw)Nr)	rnrjr�r�r=�_safe_readintoror�bytes)rAr��total_bytes�mvbrorB�temp_mvbs       r)r�zHTTPResponse._readinto_chunkedas����|�|�x�'�'�'�����m��	:��!�1�1�3�
��%�&�&��s�8�z�)��+�+�C�0�A�&0�1�n�D�O�&��?�*��{�
�+���'�'��1���!�"�g���q� ��"#����� �	:� ��q��;�'7�!8�9�9�	:�s�B�-B�'(B�!B0c��|jj|�}t|�|krt||t|�z
��|S)aRead the number of bytes requested.

        This function should be used when <amt> bytes "should" be present for
        reading. If the bytes are truly not available (due to EOF), then the
        IncompleteRead exception can be used to detect the problem.
        )rRr�r=r)rAr�r&s   r)r�zHTTPResponse._safe_readys;���w�w�|�|�C� ���t�9�s�?� ��s�3�t�9�}�5�5��r6c��t|�}|jj|�}||krtt	|d|�||z
��|S)z2Same as _safe_read, but for reading into a buffer.N)r=rRr�rr�)rAr�r�rBs    r)r�zHTTPResponse._safe_readinto�sF���!�f���G�G���Q����s�7� ��q��!�u��s�1�u�5�5��r6c��|j�|jdk(ry|jr|j|�S|j� |dks||jkDr|j}|jj|�}|s|r|j
�|S|j�:|xjt|�zc_|js|j
�|S)zvRead with at most one underlying system call.  If at least one
        byte is buffered, return that instead.
        r�r6r)rRrhrn�_read1_chunkedrp�read1r~r=)rArB�results   r)r�zHTTPResponse.read1�s����7�7�?�d�l�l�f�4���<�<��&�&�q�)�)��;�;�"��A���T�[�[�����A������q�!���!�����
�
�	�[�[�
$��K�K�3�v�;�&�K��;�;�� � �"��
r6c��|j�|jdk(ry|jr|j|�S|jj	|�S)Nr�r6)rRrhrn�
_peek_chunked�peek)rArBs  r)r�zHTTPResponse.peek�sE���7�7�?�d�l�l�f�4���<�<��%�%�a�(�(��w�w�|�|�A��r6c���|j�|jdk(ry|jrt�|�|�S|j
� |dks||j
kDr|j
}|jj	|�}|s|r|j
�|S|j
�:|xj
t|�zc_|j
s|j
�|S)Nr�r6r)rRrhrnr�rOrpr~r=)rA�limitr�r�s   �r)rOzHTTPResponse.readline�s�����7�7�?�d�l�l�f�4���<�<��7�#�E�*�*��;�;�"���	�U�T�[�[�5H��K�K�E����!�!�%�(���%�����
�
�	�[�[�
$��K�K�3�v�;�&�K��;�;�� � �"��
r6c���|j�}|�|dk(ryd|cxkr|ksn|}|jj|�}|xjt	|�zc_|std��|Sr�)r�rRr�ror=r)rArBror�s    r)r�zHTTPResponse._read1_chunked�sj���)�)�+�
����a����Q�$�*�$��A��w�w�}�}�Q������3�t�9�$��� ��%�%��r6c��	|j�}|�y|jj|�d|S#t$rYywxYw)Nr6)r�rrRr�)rArBros   r)r�zHTTPResponse._peek_chunked�sP��	��-�-�/�J�����w�w�|�|�J�'���4�4��
�	��	�s�3�	?�?c�6�|jj�Sr�)rR�filenor�s r)r�zHTTPResponse.fileno�s���w�w�~�~��r6c���|j�
t��|jj|�xs|}t|t�st|d�s|Sdj
|�S)axReturns the value of the header matching *name*.

        If there are multiple matching headers, the values are
        combined into a single string separated by commas and spaces.

        If no matching header is found, returns *default* or None if
        the *default* is not specified.

        If the headers are unknown, raises http.client.ResponseNotReady.

        �__iter__z, )rSr�get_all�
isinstancery�hasattrrX)rAr'�defaultrSs    r)�	getheaderzHTTPResponse.getheader�sW���<�<��"�$�$��,�,�&�&�t�,�7����g�s�#�7�7�J�+G��N��9�9�W�%�%r6c�t�|j�
t��t|jj��S)z&Return list of (header, value) tuples.)rSr�listr�r�s r)�
getheaderszHTTPResponse.getheaders�s-���<�<��"�$�$��D�L�L�&�&�(�)�)r6c��|Sr�rJr�s r)r�zHTTPResponse.__iter__�s���r6c��|jS)ajReturns an instance of the class mimetools.Message containing
        meta-information associated with the URL.

        When the method is HTTP, these headers are those returned by
        the server at the head of the retrieved HTML page (including
        Content-Length and Content-Type).

        When the method is FTP, a Content-Length header will be
        present if (as is now usual) the server passed back a file
        length in response to the FTP retrieval request. A
        Content-Type header will be present if the MIME type can be
        guessed.

        When the method is local-file, returned headers will include
        a Date representing the file's last-modified time, a
        Content-Length giving file size, and a Content-Type
        containing a guess at the file's type. See also the
        description of the mimetools module.

        )rSr�s r)�infozHTTPResponse.info�s��*�|�|�r6c��|jS)aZReturn the real URL of the page.

        In some cases, the HTTP server redirects a client to another
        URL. The urlopen() function handles this transparently, but in
        some cases the caller needs to know which URL the client was
        redirected to. The geturl() method can be used to get at this
        redirected URL.

        )rtr�s r)�geturlzHTTPResponse.geturls
���x�x�r6c��|jS)zuReturn the HTTP status code that was sent with the response,
        or None if the URL is not an HTTP URL.

        )rlr�s r)�getcodezHTTPResponse.getcodes��
�{�{�r6)rNNr�)���)"rGrHrIrur�r�r�r~r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rOr�r�r�r�r�r�r�r�r��
__classcell__�r�s@r)rr�s����#�<'�BF#�P�:�
#��
��&�P �D� ��0;�$:�0
���&��"�5� �&�(*��
�.
�r6rc��tj�}|dk(r|jdg�|j�d|_|S)Nr�zhttp/1.1T)�ssl�_create_default_https_context�set_alpn_protocols�post_handshake_auth)�http_version�contexts  r)�_create_https_contextr�$sC���/�/�1�G��r���"�"�J�<�0��"�"�.�&*��#��Nr6c�
�eZdZdZdZeZeZdZ	dZ
ed��Zed��Z
dejddfd	�Zd"d
�Zd�Zd�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd#d�Z		d$d�Zd�Zd�Zd�Z d�Z!d�Z"d%dd�d�Z#difdd�d�Z$d �Z%d!�Z&y)&rr�zHTTP/1.1r;rc�6�t|tj�S)zFTest whether a file-like object is a text or a binary stream.
        )r��io�
TextIOBase)�streams r)�
_is_textIOzHTTPConnection._is_textIO;s���&�"�-�-�0�0r6c���|�|j�tvryyt|d�ry	t|�}|jS#t
$rYnwxYwt
|t�rt|�Sy)aGet the content-length based on the body.

        If the body is None, we set Content-Length: 0 for methods that expect
        a body (RFC 7230, Section 3.3.2). We also set the Content-Length for
        any method if the body is a str or bytes-like object and not a file.
        Nrr�)	�upper�_METHODS_EXPECTING_BODYr�r��nbytes�	TypeErrorr�ryr=)�bodyrs�mvs   r)�_get_content_lengthz"HTTPConnection._get_content_lengthAsq���<��|�|�~�!8�8����4�� ��	��D�!�B��9�9����	��	���d�C� ��t�9��s�A�	A�AN� c�R�||_||_||_d|_g|_d|_t|_d|_d|_	d|_
i|_d|_|j||�\|_|_|j!|j�t"j$|_yr�)�timeout�source_address�	blocksizerr�_buffer�_HTTPConnection__response�_CS_IDLE�_HTTPConnection__staterh�_tunnel_host�_tunnel_port�_tunnel_headers�_raw_proxy_headers�
_get_hostport�host�port�_validate_host�socket�create_connection�_create_connection)rArrrrrs      r)ruzHTTPConnection.__init__as������,���"�����	������������� ��� ���!���"&���!%�!3�!3�D�$�!?����D�I����D�I�I�&�#)�":�":��r6c��|jrtd��|j||�\|_|_|r|j�|_n|jj�td�|jD��sI|jjd�jd�}d||jfz|jd<yy)a�Set up host and port for HTTP CONNECT tunnelling.

        In a connection that uses HTTP CONNECT tunnelling, the host passed to
        the constructor is used as a proxy server that relays all communication
        to the endpoint passed to `set_tunnel`. This done by sending an HTTP
        CONNECT request to the proxy server when the connection is established.

        This method must be called before the HTTP connection has been
        established.

        The headers argument should be a mapping of extra HTTP headers to send
        with the CONNECT request.

        As HTTP/1.1 is used for HTTP CONNECT tunnelling request, as per the RFC
        (https://tools.ietf.org/html/rfc7231#section-4.3.6), a HTTP Host:
        header must be provided, matching the authority-form of the request
        target provided as the destination for the CONNECT request. If a
        HTTP Host: header is not provided via the headers argument, one
        is generated and transmitted automatically.
        z.Can't set up tunnel for established connectionc3�BK�|]}|j�dk(���y�w)rN�r<)�.0�headers  r)�	<genexpr>z,HTTPConnection.set_tunnel.<locals>.<genexpr>�s����O��6�<�<�>�V�+�O�s��idna�asciiz%s:%d�HostN)rr�RuntimeErrorrr
r�copyr�clear�anyrrY)rArrrS�encoded_hosts     r)�
set_tunnelzHTTPConnection.set_tunnelxs���,�9�9��O�P�P�/3�/A�/A�$��/M�,���4�,��#*�<�<�>�D� �� � �&�&�(��O�$�:N�:N�O�O��,�,�3�3�F�;�B�B�7�K�L�+2��d�/�/�61�,1�D� � ��(�Pr6c�H�|�K|jd�}|jd�}||kDr	t||dzd�}|d|}n|j}|r|ddk(r
|ddk(r|dd}||fS#t$r/||dzddk(r
|j}nt	d||dzdz��Y�dwxYw)	Nr:�]r;rxznonnumeric port: '%s'r�[r�)�rfindrr}�default_portr)rArrr��js     r)rzHTTPConnection._get_hostport�s����<��
�
�3��A��
�
�3��A��1�u�O��t�A�a�C�D�z�?�D��B�Q�x���(�(���D��G�s�N�t�B�x�3����"�:�D��d�|���"�O��A�a�C�D�z�R�'�#�0�0��(�)@�4��!���:�)M�N�N��O�s�A)�)5B!� B!c��||_yr�)rg)rA�levels  r)�set_debuglevelzHTTPConnection.set_debuglevel�s	����r6c�.�d|vr|ddk7rd|zdzS|S)N�:r�[r/r0rJ)rA�ips  r)�
_wrap_ipv6zHTTPConnection._wrap_ipv6�s(���2�:�"�Q�%�7�*��"�9�t�#�#��	r6c��d|j|jjd��|j|jjd�fz}|g}|j
j
�D]+\}}|j|�d|�d�jd���-|jd�|jdj|��~|j|j|j�	�}	|j�\}}}t|j�|_|j"d
kDr+|j D]}t%d|j'���|t(j*j,k7r/|j/�t1d|�d
|j3�����	|j/�y#|j/�wxYw)NsCONNECT %s:%d %s
rrz: �
rrMr6�rsrr�zTunnel connection failed: � )r1r
rr�
_http_vsn_strrr�r@�sendrX�response_classrrrhr�rTrRr
rgrzrY�http�
HTTPStatus�OKr��OSErrorr�)	rA�connectrSrr��responserkr��messages	         r)�_tunnelzHTTPConnection._tunnel�s���)��O�O�D�-�-�4�4�V�<�=�������%�%�g�.�-0�0���)��!�1�1�7�7�9�	G�M�F�E��N�N�f�X�R��w�d�3�:�:�9�E�F�	G����w��	
�	�	�#�(�(�7�#�$���&�&�t�y�y����&�F��	�'/�'<�'<�'>�$�W�d�G�&3�H�K�K�&@�D�#�����"�"�5�5�6�F��)�V�]�]�_�5�6��t���)�)�)��
�
��� :�4�&��'�-�-�/�AR�S�T�T�*�

�N�N���H�N�N��s
�9B4F?�?Gc�H�|j�t|j�SdS)z�
        Returns a dictionary with the headers of the response
        received from the proxy server to the CONNECT request
        sent to set the tunnel.

        If the CONNECT request was not sent, the method returns None.
        N)r
r`r�s r)�get_proxy_response_headersz)HTTPConnection.get_proxy_response_headers�s/���&�&�2�
 �� 7� 7�8�	
��	
r6c��tjd||j|j�|j	|j|jf|j
|j�|_	|jjtjtjd�|jr|j!�yy#t$r(}|jtjk7r�Yd}~�Jd}~wwxYw)z3Connect to the host and port specified in __init__.zhttp.client.connectr;N)�sys�auditrrrrrrr�
setsockoptr�IPPROTO_TCP�TCP_NODELAYr<�errno�ENOPROTOOPTr
r@�rA�es  r)r=zHTTPConnection.connect�s����	�	�'��t�y�y�$�)�)�D��+�+�
�Y�Y�t�y�y�!�4�<�<��1D�1D�F��	�	��I�I� � ��!3�!3�V�5G�5G��K�
����L�L�N���	�	��w�w�%�+�+�+��,��	�s�09C�	C8�C3�3C8c��t|_	|j}|rd|_|j�|j}|rd|_|j�yy#|j}|rd|_|j�wwxYw)z(Close the connection to the HTTP server.N)rr	rrr�r)rArrr>s   r)r�zHTTPConnection.close�sr�����		!��9�9�D�� ��	��
�
�����H��"&������ ������H��"&������ ��s�%A�(Bc��|j�'|jr|j�n
t��|jdkDrtdt
|��t|d�r�|jdkDrtd�|j|�}|r|jdkDrtd�|j|j�x}rc|r|jd�}tjd||�|jj|�|j|j�x}r�cytjd||�	|jj|�y#t$r`t!|t"j$j&�r$|D]}|jj|��Yytd	t)|�z��wxYw)
z�Send `data' to the server.
        ``data`` can be a string object, a bytes object, an array object, a
        file-like object that supports a .read() method, or an iterable object.
        Nrzsend:r�zsending a readable�encoding file using iso-8859-1rVzhttp.client.sendz9data should be a bytes-like object or an iterable, got %r)rr�	auto_openr=rrgrzr{r�r�r�rrrDrE�sendallr�r��collections�abc�Iterable�type)rAr&r�	datablock�ds     r)r7zHTTPConnection.sends����9�9���~�~�����"�n�$��?�?�Q���'�4��:�&��4�� �����"��*�+��_�_�T�*�F��$�/�/�A�-��6�7�#�y�y����8�8�)�8�� )� 0� 0�� >�I��	�	�,�d�I�>��	�	�!�!�)�,�	 $�y�y����8�8�)�8�

��	�	�$�d�D�1�	G��I�I���d�#���	G��$���� 8� 8�9��)�A��I�I�%�%�a�(�)� �!9�;?��:�!F�G�G�	G�s�E � AG	�1G	c�:�|jj|�y)zuAdd a line of output to the current request buffer.

        Assumes that the line does *not* end with \r\n.
        N)rr@)rAr�s  r)�_outputzHTTPConnection._output(s��
	
�����A�r6c#�@K�|jdkDrtd�|j|�}|r|jdkDrtd�|j|j�x}r6|r|jd�}|��|j|j�x}r�5yy�w)Nrzreading a readablerOrV)rgrzr�r�rr)rAr�rrVs    r)�_read_readablezHTTPConnection._read_readable/s������?�?�Q���&�'�����*���d�o�o��)��2�3�#�=�=����8�8�i�8��%�,�,�\�:�	��O�$�=�=����8�8�i�8�s�BB�BFc��|jjd�dj|j�}|jdd�=|j|�|��t	|d�r|j|�}n	t
|�|f}|D]e}|s|jdkDrtd�� |r3|jdk(r$t|�d	�d
�jd�|zdz}|j|��g|r"|jdk(r|jd�yyyy#t$r4	t|�}n$#t$rtdt|�z��wxYwY��wxYw)
z�Send the currently buffered request and clear the buffer.

        Appends an extra \r\n to the buffer.
        A message_body may be specified, to be appended to the request.
        )r6r6rMNr�zAmessage_body should be a bytes-like object or an iterable, got %rrzZero length chunk ignoredr��Xr3rs0

)r�extendrXr7r�r[r�r��iterrUrgrz�	_http_vsnr=r)rA�message_body�encode_chunkedri�chunks�chunks      r)�_send_outputzHTTPConnection._send_output:se��	
�����J�'��l�l�4�<�<�(���L�L��O��	�	�#���#��|�V�,��,�,�\�:��-�
�|�,�+�_�F��

!�������*��9�:��!�d�n�n��&:�"�5�z�!�n�D�1�8�8��A�E�I�!�"�E��	�	�%� �

!��$�.�.�B�"6��	�	�,�'�#7�~�O$��!�>�>�!%�l�!3���$�>�'�)H�*.�|�*<�)=�>�>�>���>�s*�8D�	E� D,�+E�,!E
�
E�Ec�z�|jr!|jj�rd|_|jtk(rt|_nt|j��|j
|�||_|xsd}|j|�|�d|�d|j��}|j|j|��|jdk(�r&|�s
d}|jd�rt|�\}}}}}|r.	|jd�}|j#d	t%|��n�|j&r|j&}	|j(}
n|j*}	|j,}
	|	jd�}|j/|�}d
|	vrt%|�}|
|j0k(r|j#d	|�n(|j3d�}|j#d	|�d
|
���|s|j#dd�yyy#t $r|jd�}Y��	wxYw#t $r|	jd�}Y��wxYw)
a`Send a request to the server.

        `method' specifies an HTTP request method, e.g. 'GET'.
        `url' specifies the object being requested, e.g. '/index.html'.
        `skip_host' if True does not add automatically a 'Host:' header
        `skip_accept_encoding' if True does not add automatically an
           'Accept-Encoding:' header
        N�/r5r�rxr9rrrr:zAccept-Encoding�identity)rr�r	r�_CS_REQ_STARTEDr�_validate_methodrh�_validate_pathr6rY�_encode_requestr`r2rrr �	putheaderr5r
rrrr1r(rY)rArsrt�	skip_host�skip_accept_encoding�request�netloc�nil�
netloc_encrr�host_encs            r)�
putrequestzHTTPConnection.putrequestps����?�?�t���7�7�9�"�D�O�*�<�<�8�#�*�D�L�#�D�L�L�1�1����f�%�����j�S�����C� � &��T�-?�-?�@�����T�)�)�'�2�3��>�>�R������>�>�&�)�19�#��.�C���c�3��;�%+�]�]�7�%;�
��N�N�6�+<�Z�+H�I��(�(�#�0�0��#�0�0��#�y�y��#�y�y��7�#'�;�;�w�#7�� $���x�8�H��d�{�#4�X�#>���t�0�0�0����v�x�8�#+�?�?�7�#;�����v�(�D�/I�J�(����0�*�=�(�
��c.�;�%+�]�]�6�%:�
�;��.�7�#'�;�;�v�#6��7�s$�?G<�*H�<H�H�H:�9H:c�$�|jd�S)Nr)r)rArps  r)rlzHTTPConnection._encode_request�s���~�~�g�&�&r6c�r�tj|�}|r td|�d|j��d���y)z&Validate a method name for putrequest.z)method can't contain control characters. � (found at least �)N)�$_contains_disallowed_method_pchar_re�searchr}�group)rArs�matchs   r)rjzHTTPConnection._validate_method�sI��5�;�;�F�C����?��z�J'�',�{�{�}�&7�q�:�;�
;�r6c�r�tj|�}|r td|�d|j��d���y)zValidate a url for putrequest.�&URL can't contain control characters. rxryN��!_contains_disallowed_url_pchar_rer{rr|)rArtr}s   r)rkzHTTPConnection._validate_path�sL��2�8�8��=����E�c�W�M0�05���
�/@��C�D�
D�r6c�r�tj|�}|r td|�d|j��d���y)z9Validate a host so it doesn't contain control characters.rrxryNr�)rArr}s   r)rzHTTPConnection._validate_hostsL��2�8�8��>����E�d�X�N0�05���
�/@��C�D�
D�r6c��|jtk7r
t��t|d�r|j	d�}t|�st
d|����t|�}t|�D]r\}}t|d�r|j	d�||<n-t|t�rt|�j	d�||<t||�s�ct
d||����dj|�}|dz|z}|j|�y)	zkSend a request header line to the server.

        For example: h.putheader('Accept', 'text/html')
        rrzInvalid header name rzInvalid header value s
	s: N)r	rirr�r�_is_legal_header_namer}r��	enumerater�rry�_is_illegal_header_valuerXrY)rAr�valuesr��	one_valuer�s      r)rmzHTTPConnection.putheaders���
�<�<�?�*�"�$�$��6�8�$��]�]�7�+�F�$�V�,���A�B�B��f���%�f�-�	K�L�A�y��y�(�+�%�,�,�Y�7��q�	��I�s�+��	�N�1�1�'�:��q�	�'��q�	�2� �f�Q�i�!I�J�J�	K����v�&���%��%�'�����V�r6�rbc�|�|jtk(rt|_n
t��|j	||��y)z�Indicate that the last header line has been sent to the server.

        This method sends the request to the server.  The optional message_body
        argument can be used to pass a message body associated with the
        request.
        r�N)r	ri�_CS_REQ_SENTrre)rArarbs   r)�
endheaderszHTTPConnection.endheaders(s3���<�<�?�*�'�D�L�"�$�$����,�~��Fr6c�.�|j|||||�y)z&Send a complete request to the server.N)�
_send_request)rArsrtr�rSrbs      r)rpzHTTPConnection.request5s��	
���6�3��g�~�Fr6c�
�td�|D��}i}d|vrd|d<d|vrd|d<|j||fi|��d|vrjd|vrhd	}|j||�}|�4|�P|jd
kDrt	d|z�d}|jd
d�n|jdt
|��nd	}|j�D]\}	}
|j|	|
��t|t�rt|d�}|j||��y)Nc3�<K�|]}|j����y�wr�r)r�ks  r)rz/HTTPConnection._send_request.<locals>.<genexpr><s���� <�q����� <�s�rr;rnzaccept-encodingror�r�FrzUnable to determine size of %rTzTransfer-EncodingrnzContent-Lengthr�r�)�	frozensetrurrgrzrmryr�r�r*r�)rArsrtr�rSrb�header_names�skips�content_lengthr�r�s           r)r�zHTTPConnection._send_request:s �� � <�G� <�<�����\�!�!"�E�+����,�,-�E�(�)�������-�u�-��<�/�#�,�6�"'��!%�!9�!9�$��!G��!�)��'��?�?�Q�.�!�"B�T�"I�J�)-�����':�I�F��N�N�#3�S��5H�I�"�N�!�-�-�/�	'�J�C���N�N�3��&�	'��d�C� ��4��(�D�����^��<r6c��|jr!|jj�rd|_|jtk7s|jrt	|j��|j
dkDr3|j
|j|j
|j��}n'|j
|j|j��}		|j�|jtk7sJ�t|_|jr|j�|S||_|S#t$r|j��wxYw#|j��xYw)a)Get the response from the server.

        If the HTTPConnection is in the correct state, returns an
        instance of HTTPResponse or of whatever object is returned by
        the response_class variable.

        If a request has not been sent or if a previous response has
        not be handled, ResponseNotReady is raised.  If the HTTP
        response indicates that the connection should be closed, then
        it will be closed before the response is returned.  When the
        connection is closed, the underlying socket is closed.
        Nrr4)rr�r	r�rrgr8rrrhr��ConnectionErrorr�rqrjr)rAr>s  r)�getresponsezHTTPConnection.getresponsehs ���?�?�t���7�7�9�"�D�O�"�<�<�<�'�4�?�?�"�4�<�<�0�0��?�?�Q���*�*�4�9�9�d�o�o�26�,�,�+�@�H��*�*�4�9�9�T�\�\�*�J�H�	�
���� ��&�&�(�2�2�2�#�D�L��"�"��
�
��
�O�#+����O��#�
��
�
���
��	��N�N���s$�
D$�=E�E�$D?�?E�E)NN)NF)FFr�)'rGrHrIr`r6rr8�	HTTP_PORTr(rPrg�staticmethodr�rr�_GLOBAL_DEFAULT_TIMEOUTrur#rr,r1r@rBr=r�r7rYr[rerurlrjrkrrmr�rpr�r�rJr6r)rr1s����I��M�!�N��L��I��J��1��1�
����>#'��0N�0N� $��;�."1�H�( ��
�@
�
�!�#G�J�	�4(�l16�(-�}�~'�;�D�D��8G�e�G�)-�b�G�$�G�
,=�\=r6rc�R��eZdZdZeZdejdddd��fd�Z�fd�Z	�xZ
S)�HTTPSConnectionz(This class allows communication via SSL.Nr)rrr�rc�r��tt|�|||||��|�t|j�}||_y)N)r)r�r�rur�r`�_context)rArrrrr�rr�s       �r)ruzHTTPSConnection.__init__�sB���
�/�4�1�$��g�2@�<E�
2�
G���/����?��#�D�Mr6c����t�|��|jr
|j}n|j}|jj|j|��|_y)z(Connect to a host on a given (SSL) port.)�server_hostnameN)r�r=r
rr��wrap_socketrr)rAr�r�s  �r)r=zHTTPSConnection.connect�sQ���
�G�O��� � �"&�"3�"3��"&�)�)���
�
�1�1�$�)�)�BQ�2�S�D�Ir6r�)rGrHrI�__doc__�
HTTPS_PORTr(rr�rur=r�r�s@r)r�r��s1���2�!��	$� &� >� >�$(�$�$�	$�	S�	Sr6r�c��eZdZy)rN�rGrHrIrJr6r)rr�s��	r6rc��eZdZy)rNr�rJr6r)rr����r6rc��eZdZy)rNr�rJr6r)rr�r�r6rc��eZdZd�Zy)rc�"�|f|_||_yr�)�argsrk)rArks  r)ruzUnknownProtocol.__init__�s���H��	���r6N�rGrHrIrurJr6r)rr�s��r6rc��eZdZy)r	Nr�rJr6r)r	r	�r�r6r	c��eZdZy)r
Nr�rJr6r)r
r
�r�r6r
c�2�eZdZdd�Zd�ZejZy)rNc�0�|f|_||_||_yr�)r��partial�expected)rAr�r�s   r)ruzIncompleteRead.__init__�s���H��	���� ��
r6c��|j�d|jz}nd}d|jjt|j�|fzS)Nz, %i more expectedrxz%s(%i bytes read%s))r�r�rGr=r�rKs  r)�__repr__zIncompleteRead.__repr__�sK���=�=�$�$�t�}�}�4�A��A�$����(?�(?�(+�D�L�L�(9�1�(>�>�	>r6r�)rGrHrIrur�r"�__str__rJr6r)rr�s��!�>��n�n�Gr6rc��eZdZy)r
Nr�rJr6r)r
r
�r�r6r
c��eZdZy)rNr�rJr6r)rr�r�r6rc��eZdZy)rNr�rJr6r)rr�r�r6rc��eZdZy)rNr�rJr6r)rr�r�r6rc��eZdZd�Zy)rc�<�|st|�}|f|_||_yr�)r{r�rEr�s  r)ruzBadStatusLine.__init__�s�����:�D��E��	���	r6Nr�rJr6r)rr�s��r6rc��eZdZd�Zy)rc�B�tj|dt|fz�y)Nz&got more than %d bytes when reading %s)rrurP)rA�	line_types  r)ruzLineTooLong.__init__s"�����t�%M�(0�)�'<�&=�	>r6Nr�rJr6r)rrs��>r6rc��eZdZd�Zy)rc�b�tj|d�tj|g|��i|��y)Nrx)rru�ConnectionResetError)rA�pos�kws   r)ruzRemoteDisconnected.__init__s*�����t�R�(��%�%�d�7�S�7�B�7r6Nr�rJr6r)rrs��8r6r)r&)Hr��email.parserrZ�
email.messagerIr9r��rerrD�collections.abcrR�urllib.parser�__all__r�r�rjrrir��globals�updater:�__members__r��phraserrPrQ�compile�	fullmatchr�r{r�r�rzr�r*r�r5r?�Messager8rTr`rb�BufferedIOBaserr�rr�r�r@�ImportError�	Exceptionrrrrr	r
rr
rrrrrr�rr)�vs0r)�<module>r�sq��D�L����	�	�
�
��!���
�	�
�
�����#�����	������,�,�-�#'�/�/�"=�"=�"D�"D�"F�G�Q�Q����[�G�	�����6#��
�
�#6�7�A�A��%�2�:�:�&C�D�K�K��%/�B�J�J�/@�$A�!�(2�r�z�z�-�'@�$�3��E����%���%�-�-�'�'��<�$.9�@�)�0�e�2�$�$�e�P
�t	�t	�l!&��S�.�S�8�N�N�$�%�	�I�	�
	�=�	�	��	��m��
	�m�	�	�M�	��]��	�m�	�	�/�	�	�.�	�	�.�	��M��>�-�>�
8�-�}�8�	���A-
H��z)�	��	�s�
H!�#H&�&H.�-H.

Zerion Mini Shell 1.0