ok

Mini Shell

Direktori : /proc/thread-self/root/opt/alt/python311/lib64/python3.11/http/__pycache__/
Upload File :
Current File : //proc/thread-self/root/opt/alt/python311/lib64/python3.11/http/__pycache__/client.cpython-311.pyc

�

�f����N�dZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Zddlm
Z
gd�ZdZdZdZdZd	Zd
Ze���ejj��d�ejj���D��ZdZd
Zejd��jZejd��j Z!ejd��Z"ejd��Z#hd�Z$d>d�Z%de&de&fd�Z'Gd�dej(j)��Z*d�Z+e*fd�Z,Gd�dej-��Z.Gd�d��Z/	ddl0Z0Gd �d!e/��Z1e�2d!��n#e3$rYnwxYwGd"�d#e4��Z5Gd$�d%e5��Z6Gd&�d'e5��Z7Gd(�d)e5��Z8Gd*�d+e5��Z9Gd,�d-e5��Z:Gd.�d/e5��Z;Gd0�d1e5��Z<Gd2�d3e<��Z=Gd4�d5e<��Z>Gd6�d7e<��Z?Gd8�d9e5��Z@Gd:�d;e5��ZAGd<�d=eBe@��ZCe5ZDdS)?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-sentc��i|]
}||j��S�)�phrase)�.0�vs  �2/opt/alt/python311/lib64/python3.11/http/client.py�
<dictcomp>rls��G�G�G�Q�Q���G�G�G�i�ds[^:\s][^:\r\n]*s\n(?![ \t])|\r(?![ \t\n])z[- ]z[-]>�PUT�POST�PATCH�datac
��	|�d��S#t$r[}t|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)r%�name�errs   r�_encoder1�s���
E��{�{�9�%�%�%���E�E�E� ��L��J��I��G��Z�Z�\�\�\�\�4��	�#�'� 1�2�2�2�2�D�D�D�
:�;�;�AE�	E�����E���s��
A<�AA7�7A<�enc_name�returnc��|�d��\}}}|r$|�d��s
J|���|dz
}|S)z)Remove interface scope from IPv6 address.�%�[�])�	partition�
startswith)r2�percent�_s   r�_strip_ipv6_ifacer<�sU��#�-�-�d�3�3��H�g�q����"�"�4�(�(�2�2�(�2�2�(��D����Or c��eZdZd�ZdS)�HTTPMessagec�8�|���dz}t|��}g}d}|���D]Z}|d|����|krd}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.

        �:rN�)�lower�len�keys�isspace�append)�selfr/�n�lst�hit�lines      r�getallmatchingheadersz!HTTPMessage.getallmatchingheaders�s����z�z�|�|�c�!����I�I�������I�I�K�K�	!�	!�D��B�Q�B�x�~�~���4�'�'�����"�1�"�X�%�%�'�'�
����
!��
�
�4� � � ���
r N)�__name__�
__module__�__qualname__rLrr rr>r>�s#����������r r>c�(�g}	|�tdz��}t|��tkrtd���|�|��t|��t
krt
dt
z���|dvrn��|S)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.
    TrA�header linezgot more than %d headers��
�
r )�readline�_MAXLINErCrrF�_MAXHEADERSr)�fp�headersrKs   r�
_read_headersrZ�s����G���{�{�8�a�<�(�(���t�9�9�x����m�,�,�,����t�����w�<�<�+�%�%�� :�[� H�I�I�I��(�(�(����Nr c���t|��}d�|���d��}tj�|����|��S)aGParses 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.

    r �
iso-8859-1)�_class)rZ�join�decode�email�parser�Parser�parsestr)rXr]rY�hstrings    r�
parse_headersre�sW���B���G��h�h�w���&�&�|�4�4�G��<���f��-�-�6�6�w�?�?�?r c����eZdZd"d�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)%rrNc��|�d��|_||_||_dx|_|_t|_t|_t|_	t|_
t|_t|_t|_
dS)N�rb)�makefilerX�
debuglevel�_methodrY�msg�_UNKNOWN�version�status�reason�chunked�
chunk_left�length�
will_close)rG�sockrj�method�urls     r�__init__zHTTPResponse.__init__�sl���-�-��%�%���$������#'�&���t�x� ������������"������"����r c���t|j�tdz��d��}t	|��tkrtd���|jdkrtdt|����|std���	|�
dd��\}}}n?#t$r2	|�
dd��\}}d}n#t$rd}YnwxYwYnwxYw|�d	��s#|�
��t|���	t|��}|d
ks|dkrt|���n#t$rt|���wxYw|||fS)NrAr\zstatus linerzreply:z-Remote end closed connection without response��zHTTP/r!i�)�strrXrUrVrCrrj�print�reprr�split�
ValueErrorr9�_close_connr�int)rGrKrnrorps     r�_read_statuszHTTPResponse._read_statuss����4�7�#�#�H�q�L�1�1�<�@�@���t�9�9�x����m�,�,�,��?�Q����(�D��J�J�'�'�'��	2�%�&1�2�2�
2�	�&*�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��|j�dS	|���\}}}|tkrn1t|j��}|jdkrt
d|��~�U|x|_|_|�	��|_
|dvrd|_n,|�d��rd|_nt|���t|j��x|_|_|jdkr3|j���D]\}}t
d|d	z|���|j�d
��}|r'|���dkrd|_d|_nd|_|���|_d|_|j�d
��}|rF|js?	t1|��|_|jdkrd|_n#t2$r
d|_YnwxYwd|_|t4ks%|t6ksd|cxkrdks
n|jdkrd|_|js|js|j�
d|_dSdSdSdS)NTrzheaders:)zHTTP/1.0zHTTP/0.9�
zHTTP/1.��header:r@�transfer-encodingrqF�content-lengthr!���HEAD)rYr��CONTINUErZrXrjr}�codero�striprprnr9rrerl�items�getrBrqrr�_check_closertrsr�r��
NO_CONTENT�NOT_MODIFIEDrk)	rGrnrorp�skipped_headers�hdr�val�tr_encrss	         r�beginzHTTPResponse.begin>s����<�#��F�	 �&*�&7�&7�&9�&9�#�G�V�V���!�!��+�D�G�4�4�O����"�"��j�/�2�2�2��	 �#)�(��	�D�K��l�l�n�n����.�.�.��D�L�L�
�
�
�	�
*�
*�	+��D�L�L�!�'�*�*�*�"/���"8�"8�8���t�x��?�Q��� �L�.�.�0�0�
1�
1���S��i��s��C�0�0�0�0���!�!�"5�6�6���	!�f�l�l�n�n�	�1�1��D�L�"�D�O�O� �D�L��+�+�-�-��������!�!�"2�3�3���		�$�,�		�
'�!�&�k�k����;��?�?�"&�D�K���	�
#�
#�
#�"�����
#�����D�K�
�j� � �F�l�$:�$:��6�����C������L�F�"�"��D�K�
��	#���	#��K��"�D�O�O�O�	#�	#�	#�	#��s�+G�G&�%G&c�\�|j�d��}|jdkr|rd|���vrdSdS|j�d��rdS|rd|���vrdS|j�d��}|rd|���vrdSdS)N�
connectionr��closeTFz
keep-alivezproxy-connection)rYr�rnrB)rG�conn�pconns   rr�zHTTPResponse._check_close�s����|����-�-���<�2����
��4�:�:�<�<�/�/��t��5��<���L�)�)�	��5��	�L�D�J�J�L�L�0�0��5��� � �!3�4�4���	�\�U�[�[�]�]�2�2��5��tr c�J�|j}d|_|���dS�N)rXr�)rGrXs  rr�zHTTPResponse._close_conn�s!��
�W�����
���
�
�
�
�
r c����	t�����|jr|���dSdS#|jr|���wwxYwr�)�superr�rXr��rG�	__class__s �rr�zHTTPResponse.close�sl���	#��G�G�M�M�O�O�O��w�
#�� � �"�"�"�"�"�
#�
#��t�w�
#�� � �"�"�"�"�
#���s� A�A c���t�����|jr|j���dSdSr�)r��flushrXr�s �rr�zHTTPResponse.flush�s;���
���
�
�����7�	��G�M�M�O�O�O�O�O�	�	r c��dS)zAlways returns TrueTr�rGs r�readablezHTTPResponse.readable�s���tr c��|jduS)z!True if the connection is closed.N)rXr�s r�isclosedzHTTPResponse.isclosed�s���w�$��r c��|j�dS|jdkr|���dS|jr|�|��S|��|j�||jkr|j}|j�|��}|s|r|���n?|j�8|xjt|��zc_|js|���|S|j�|j���}nF	|�|j��}n##t$r|����wxYwd|_|���|S)z?Read and return the response body, or up to the next amt bytes.Nr r�r)
rXrkr�rq�
_read_chunkedrs�readrC�
_safe_readr)rG�amt�ss   rr�zHTTPResponse.read�sm���7�?��3��<�6�!�!��������3��<�	+��%�%�c�*�*�*��?��{�&�3���+<�+<��k������S�!�!�A��
'��
'�� � �"�"�"�"���(����s�1�v�v�%����{�'��$�$�&�&�&��H��{�"��G�L�L�N�N���������4�4�A�A��%�����$�$�&�&�&������ ����������Hs�8D� D3c���|j�dS|jdkr|���dS|jr|�|��S|j�4t
|��|jkrt|��d|j�}|j�|��}|s|r|���n2|j�+|xj|zc_|js|���|S)z^Read up to len(b) bytes into bytearray b and return the number
        of bytes read.
        Nrr�)	rXrkr�rq�_readinto_chunkedrsrC�
memoryview�readinto)rG�brHs   rr�zHTTPResponse.readinto�s���
�7�?��1��<�6�!�!��������1��<�	-��)�)�!�,�,�,��;�"��1�v�v���#�#��q�M�M�!�D�K�-�0��

�G���Q�����	#�Q�	#�
�������
�[�
$��K�K�1��K�K��;�
#�� � �"�"�"��r c�F�|j�tdz��}t|��tkrt	d���|�d��}|dkr
|d|�}	t
|d��S#t$r|����wxYw)NrAz
chunk size�;r�)	rXrUrVrCr�findr�r�r�)rGrK�is   r�_read_next_chunk_sizez"HTTPResponse._read_next_chunk_sizes����w����1��-�-���t�9�9�x����l�+�+�+��I�I�d�O�O����6�6�����8�D�	��t�R�=�=� ���	�	�	�
�������		���s�0B� B c��	|j�tdz��}t|��tkrt	d���|sdS|dvrdS�T)NTrAztrailer linerR)rXrUrVrCr�rGrKs  r�_read_and_discard_trailerz&HTTPResponse._read_and_discard_trailer#sd��		��7�#�#�H�q�L�1�1�D��4�y�y�8�#�#�!�.�1�1�1��
����,�,�,���		r c��|j}|s�|�|�d��	|���}n#t$rt	d���wxYw|dkr*|���|���d}||_|S)Nrzr r)rrr�r�r�rr�r�)rGrrs  r�_get_chunk_leftzHTTPResponse._get_chunk_left1s����_�
��	)��%�����"�"�"�
*�!�7�7�9�9�
�
���
*�
*�
*�$�S�)�)�)�
*�����Q����.�.�0�0�0�� � �"�"�"�!�
�(�D�O��s	�7�Ac���|jtksJ�g}		|���}|�nr|�9||kr3|�|�|����||z
|_n7|�|�|����|�||z}d|_��d�|��S#t$r(}td�|����|�d}~wwxYw)NTrr )rqrmr�rFr�rrr^r)rGr��valuerr�excs     rr�zHTTPResponse._read_chunkedIs����|�x�'�'�'�'���	;�

$�!�1�1�3�3�
��%���?�s�j�'8�'8��L�L�����!5�!5�6�6�6�&0�3�&6�D�O�����T�_�_�Z�8�8�9�9�9��?��:�%�C�"#���

$��8�8�E�?�?�"���	;�	;�	;� ����%���1�1�s�:�����	;���s�BB5�5
C'�?#C"�"C'c��|jtksJ�d}t|��}		|���}|�|St	|��|kr$|�|��}||z
|_||zS|d|�}|�|��}||d�}||z
}d|_��#t$r%tt|d|������wxYw)Nr)	rqrmr�r�rC�_safe_readintorrr�bytes)rGr��total_bytes�mvbrrrH�temp_mvbs       rr�zHTTPResponse._readinto_chunked_s���|�x�'�'�'�'�����m�m��	:�
$�!�1�1�3�3�
��%�&�&��s�8�8�z�)�)��+�+�C�0�0�A�&0�1�n�D�O�&��?�*��{�
�{�+���'�'��1�1���!�"�"�g���q� ��"#���
$�� �	:�	:�	:� ��q��;��'7�!8�!8�9�9�9�	:���s�B+�6B+�56B+�+/Cc��|j�|��}t|��|kr t||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.
        )rXr�rCr)rGr�r%s   rr�zHTTPResponse._safe_readwsE���w�|�|�C� � ���t�9�9�s�?�?� ��s�3�t�9�9�}�5�5�5��r c��t|��}|j�|��}||kr(tt	|d|���||z
���|S)z2Same as _safe_read, but for reading into a buffer.N)rCrXr�rr�)rGr�r�rHs    rr�zHTTPResponse._safe_readinto�sR���!�f�f���G���Q�����s�7�7� ��q��!��u���s�1�u�5�5�5��r ���c��|j�|jdkrdS|jr|�|��S|j�|dks||jkr|j}|j�|��}|s|r|���n?|j�8|xjt|��zc_|js|���|S)zvRead with at most one underlying system call.  If at least one
        byte is buffered, return that instead.
        Nr�r r)rXrkrq�_read1_chunkedrs�read1r�rC)rGrH�results   rr�zHTTPResponse.read1�s����7�?�d�l�f�4�4��3��<�	*��&�&�q�)�)�)��;�"��A����T�[�����A�����q�!�!���	#�!�	#��������
�[�
$��K�K�3�v�;�;�&�K�K��;�
#�� � �"�"�"��
r c��|j�|jdkrdS|jr|�|��S|j�|��S)Nr�r )rXrkrq�
_peek_chunked�peek)rGrHs  rr�zHTTPResponse.peek�sL���7�?�d�l�f�4�4��3��<�	)��%�%�a�(�(�(��w�|�|�A���r c���|j�|jdkrdS|jr!t���|��S|j�|dks||jkr|j}|j�|��}|s|r|���n?|j�8|xjt|��zc_|js|���|S)Nr�r r)rXrkrqr�rUrsr�rC)rG�limitr�r�s   �rrUzHTTPResponse.readline�s�����7�?�d�l�f�4�4��3��<�	+��7�7�#�#�E�*�*�*��;�"���	�	�U�T�[�5H�5H��K�E���!�!�%�(�(���	#�%�	#��������
�[�
$��K�K�3�v�;�;�&�K�K��;�
#�� � �"�"�"��
r c���|���}|�|dkrdSd|cxkr|ksn|}|j�|��}|xjt	|��zc_|std���|S)Nrr )r�rXr�rrrCr)rGrHrrr�s    rr�zHTTPResponse._read1_chunked�s����)�)�+�+�
����a����3��Q�$�$�$�$�*�$�$�$�$��A��w�}�}�Q�������3�t�9�9�$����	&� ��%�%�%��r c��	|���}n#t$rYdSwxYw|�dS|j�|��d|�S)Nr )r�rrXr�)rGrHrrs   rr�zHTTPResponse._peek_chunked�sf��	��-�-�/�/�J�J���	�	�	��3�3�	�������3��w�|�|�J�'�'����4�4s��
%�%c�4�|j���Sr�)rX�filenor�s rr�zHTTPResponse.fileno�s���w�~�~���r c���|j�t���|j�|��p|}t|t��st|d��s|Sd�|��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.

        N�__iter__z, )rYr�get_all�
isinstancer|�hasattrr^)rGr/�defaultrYs    r�	getheaderzHTTPResponse.getheader�sl���<��"�$�$�$��,�&�&�t�,�,�7����g�s�#�#�	&�7�7�J�+G�+G�	&��N��9�9�W�%�%�%r c�x�|j�t���t|j�����S)z&Return list of (header, value) tuples.)rYr�listr�r�s r�
getheaderszHTTPResponse.getheaders�s2���<��"�$�$�$��D�L�&�&�(�(�)�)�)r c��|Sr�rr�s rr�zHTTPResponse.__iter__�s���r c��|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.

        )rYr�s r�infozHTTPResponse.info�s��*�|�r c��|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.

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

        )ror�s r�getcodezHTTPResponse.getcodes��
�{�r )rNNr�)r�)"rMrNrOrxr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rUr�r�r�r�r�r�r�r�r��
__classcell__�r�s@rrr�s)�������#�#�#�#�<'�'�'�BF#�F#�F#�P���:���
#�#�#�#�#������
������&�&�&�&�P � � �D��� ������0;�;�;�;�,:�:�:�0
�
�
��������&����������"���5�5�5� � � �&�&�&�&�(*�*�*����
���.
�
�
�������r rc��eZdZdZdZeZeZdZ	dZ
ed���Zed���Z
dejddfd	�Zd!d
�Zd�Zd�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Zd"d�Z		d#d�Zd�Zd�Zd�Zd�Z d�Z!d$dd�d�Z"difdd�d�Z#d�Z$d �Z%dS)%rr�zHTTP/1.1rArc�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�0�0r c��|�|���tvrdSdSt|d��rdS	t|��}|jS#t
$rYnwxYwt
|t��rt|��SdS)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�r|rC)�bodyrv�mvs   r�_get_content_lengthz"HTTPConnection._get_content_length1s����<��|�|�~�~�!8�8�8��q��t��4�� � �	��4�	��D�!�!�B��9����	�	�	��D�	�����d�C� � �	��t�9�9���ts�A�
A�AN� c�F�||_||_||_d|_g|_d|_t|_d|_d|_	d|_
i|_|�||��\|_
|_|�|j
��t j|_dSr�)�timeout�source_address�	blocksizeru�_buffer�_HTTPConnection__response�_CS_IDLE�_HTTPConnection__staterk�_tunnel_host�_tunnel_port�_tunnel_headers�
_get_hostport�host�port�_validate_host�socket�create_connection�_create_connection)rGrr	r�r�r�s      rrxzHTTPConnection.__init__Qs������,���"�����	������������� ��� ���!���!%�!3�!3�D�$�!?�!?����D�I����D�I�&�&�&�#)�":����r c��|jrtd���|�||��\|_|_|r	||_dS|j���dS)aDSet up host and port for HTTP CONNECT tunnelling.

        In a connection that uses HTTP CONNECT tunneling, 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.
        z.Can't set up tunnel for established connectionN)ru�RuntimeErrorrrrr�clear)rGrr	rYs    r�
set_tunnelzHTTPConnection.set_tunnelgso���9�	Q��O�P�P�P�/3�/A�/A�$��/M�/M�,���4�,��	)�#*�D� � � �� �&�&�(�(�(�(�(r c��|��|�d��}|�d��}||krm	t||dzd���}nF#t$r9||dzd�dkr|j}nt	d||dzd�z���YnwxYw|d|�}n|j}|r"|ddkr|ddkr
|dd�}||fS)	Nr@�]rAr{znonnumeric port: '%s'r�[r�)�rfindr�r��default_portr)rGrr	r��js     rrzHTTPConnection._get_hostports���<��
�
�3���A��
�
�3���A��1�u�u�O��t�A�a�C�D�D�z�?�?�D�D��!�O�O�O��A�a�C�D�D�z�R�'�'�#�0���(�)@�4��!����:�)M�N�N�N���O����
�B�Q�B�x����(���	�D��G�s�N�N�t�B�x�3�����"��:�D��d�|�s�A�AB�Bc��||_dSr�)rj)rG�levels  r�set_debuglevelzHTTPConnection.set_debuglevel�s
������r c�6�d|vr|ddkrd|zdzS|S)N�:r�[r6r7r)rG�ips  r�
_wrap_ipv6zHTTPConnection._wrap_ipv6�s-���2�:�:�"�Q�%�7�*�*��"�9�t�#�#��	r c��d|�|j�d����|jfz}|g}|j���D]3\}}|�|�d|�d��d�����4|�d��|�d�|����~|�	|j
|j���}	|���\}}}|tjjkr;|���t#d	|�d
|��������	|j�t*dz��}	t-|	��t*krt/d
���|	sn3|	dvrn.|jdkr"t3d|	������|���dS#|���wxYw)NsCONNECT %s:%d HTTP/1.0
�asciiz: �
r'rSr �rvzTunnel connection failed: � TrArQrRrr�)rrr(rrr�rF�sendr^�response_classrurkr��http�
HTTPStatus�OKr��OSErrorr�rXrUrVrCrrjr}r_)
rG�connectrY�headerr��responsernr��messagerKs
          r�_tunnelzHTTPConnection._tunnel�s���/��O�O�D�-�4�4�W�=�=�>�>���3����)��!�1�7�7�9�9�	G�	G�M�F�E��N�N�f�3�3��3�3�3�:�:�9�E�E�F�F�F�F����w����	
�	�	�#�(�(�7�#�#�$�$�$���&�&�t�y���&�F�F��	�'/�'<�'<�'>�'>�$�W�d�G��t��)�)�)��
�
�����S�4�S�S�'�-�-�/�/�S�S�T�T�T�
4��{�+�+�H�q�L�9�9���t�9�9�x�'�'�%�m�4�4�4�����0�0�0���?�Q�&�&��)�T�[�[�]�]�3�3�3�
4�
�N�N�������H�N�N�������s
�(C(G&�&G<c��tjd||j|j��|�|j|jf|j|j��|_	|j�tj
tjd��n-#t$r }|j
tjkr�Yd}~nd}~wwxYw|jr|���dSdS)z3Connect to the host and port specified in __init__.zhttp.client.connectrAN)�sys�auditrr	r
r�r�ru�
setsockoptr�IPPROTO_TCP�TCP_NODELAYr*�errno�ENOPROTOOPTrr/�rG�es  rr+zHTTPConnection.connect�s����	�'��t�y�$�)�D�D�D��+�+�
�Y�t�y�!�4�<��1D�F�F��	�	��I� � ��!3�V�5G��K�K�K�K���	�	�	��w�%�+�+�+��,�+�+�+�+�����	������	��L�L�N�N�N�N�N�	�	s�0B�
B0�B+�+B0c��t|_	|j}|rd|_|���|j}|rd|_|���dSdS#|j}|rd|_|���wwxYw)z(Close the connection to the HTTP server.N)rrrur�r)rGrur-s   rr�zHTTPConnection.close�s������		!��9�D��
� ��	��
�
������H��
!�"&������ � � � � �
!�
!����H��
!�"&������ � � � �
!���s�$A�'Bc�|�|j�*|jr|���nt���|jdkrtdt
|����t|d��r�|jdkrtd��|�|��}|r|jdkrtd��	|�	|j
��}|snH|r|�d��}tj
d	||��|j�|���edStj
d	||��	|j�|��dS#t$rat!|t"jj��r"|D]}|j�|���YdStd
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-1rAr\zhttp.client.sendz9data should be a bytes-like object or an iterable, got %r)ru�	auto_openr+rrjr}r~r�r�r�r�r(r1r2�sendallr�r��collections�abc�Iterable�type)rGr%r(�	datablock�ds     rr%zHTTPConnection.send�s����9���~�
%��������"�n�n�$��?�Q����'�4��:�:�&�&�&��4�� � �	����"�"��*�+�+�+��_�_�T�*�*�F��
8�$�/�A�-�-��6�7�7�7�
-� �I�I�d�n�5�5�	� ����?� )� 0� 0�� >� >�I��	�,�d�I�>�>�>��	�!�!�)�,�,�,�
-�
�F��	�$�d�D�1�1�1�	G��I���d�#�#�#�#�#���	G�	G�	G��$��� 8�9�9�
G��)�)�A��I�%�%�a�(�(�(�(�)�)�)� �!9�;?��:�:�!F�G�G�G�	G���s�4E�AF;� F;c�:�|j�|��dS)zuAdd a line of output to the current request buffer.

        Assumes that the line does *not* end with \r\n.
        N)rrF)rGr�s  r�_outputzHTTPConnection._outputs ��
	
����A�����r c#�K�|jdkrtd��|�|��}|r|jdkrtd��	|�|j��}|sdS|r|�d��}|V��:)Nrzreading a readabler<Tr\)rjr}r�r�r�r()rGr�r(rCs    r�_read_readablezHTTPConnection._read_readables������?�Q����&�'�'�'�����*�*���	4�d�o��)�)��2�3�3�3�	� �
�
�d�n�5�5�I��
����
;�%�,�,�\�:�:�	��O�O�O�
	r Fc���|j�d��d�|j��}|jdd�=|�|��|��t	|d��r|�|��}nb	t
|��|f}nN#t$rA	t|��}n-#t$r tdt|��z���wxYwYnwxYw|D]m}|s|j
dkrtd���|r7|jdkr,t|��d	�d
��d��|zdz}|�|���n|r$|jdkr|�d��dSdSdSdS)
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.
        )r r rSNr�zAmessage_body should be a bytes-like object or an iterable, got %rrzZero length chunk ignoredr��Xr"r!s0

)r�extendr^r%r�rHr�r��iterrBrjr}�	_http_vsnrCr()rG�message_body�encode_chunkedrl�chunks�chunks      r�_send_outputzHTTPConnection._send_outputs���	
����J�'�'�'��l�l�4�<�(�(���L����O��	�	�#�����#��|�V�,�,�
-��,�,�\�:�:���-�
�|�,�,�,�+�_�F�F��!�>�>�>�>�!%�l�!3�!3����$�>�>�>�'�)H�*.�|�*<�*<�)=�>�>�>�>������>���� �

!�

!�������*�*��9�:�:�:��!�"�d�n��&:�&:�"�5�z�z�1�1�1�1�8�8��A�A�E�I�!�"�E��	�	�%� � � � ��
(�$�.�B�"6�"6��	�	�,�'�'�'�'�'�S$�#�N
(�
(�"6�"6s*�>B�
C�B,�+C�,*C�C�Cc��|jr |j���rd|_|jtkr
t|_nt|j���|�|��||_|pd}|�|��|�d|�d|j	��}|�
|�|����|jdk�r�|�shd}|�
d��rt|��\}}}}}|r`	|�d��}n%#t $r|�d��}YnwxYw|�d	t%|����n�|jr|j}	|j}
n|j}	|j}
	|	�d��}n%#t $r|	�d��}YnwxYw|�|��}d
|	vrt%|��}|
|jkr|�d	|��n0|�d��}|�d	|�d
|
����|s|�dd��dSdSdS)
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�/r$r�r{r'r!�idna�Hostr@zAccept-Encoding�identity)rr�rr�_CS_REQ_STARTEDr�_validate_methodrk�_validate_path�
_http_vsn_strrF�_encode_requestrMr9rr(r)�	putheaderr<rrrr	rrr_)rGrvrw�	skip_host�skip_accept_encoding�request�netloc�nil�
netloc_encrr	�host_encs            r�
putrequestzHTTPConnection.putrequestOs����?�	#�t��7�7�9�9�	#�"�D�O�*�<�8�#�#�*�D�L�L�#�D�L�1�1�1����f�%�%�%�����j�S�����C� � � � &������T�-?�-?�@�����T�)�)�'�2�2�3�3�3��>�R����0
K����>�>�&�)�)�?�19�#���.�C���c�3��K�;�%+�]�]�7�%;�%;�
�
��-�;�;�;�%+�]�]�6�%:�%:�
�
�
�;�����N�N�6�+<�Z�+H�+H�I�I�I�I��(�)�#�0��#�0���#�y��#�y��7�#'�;�;�w�#7�#7����-�7�7�7�#'�;�;�v�#6�#6����7����
 $���x�8�8�H��d�{�{�#4�X�#>�#>���t�0�0�0����v�x�8�8�8�8�#+�?�?�7�#;�#;�����v�(�(�(�D�D�/I�J�J�J�(�
>����0�*�=�=�=�=�=�
>�
>�
�Ds$�D�D;�:D;�F�F?�>F?c�,�|�d��S)Nr!)r()rGr`s  rr\zHTTPConnection._encode_request�s���~�~�g�&�&�&r c��t�|��}|r(td|�d|����d����dS)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)rGrv�matchs   rrYzHTTPConnection._validate_method�sf��5�;�;�F�C�C���	;��:��:�:�',�{�{�}�}�:�:�:�;�;�
;�	;�	;r c��t�|��}|r(td|�d|����d����dS)zValidate a url for putrequest.�&URL can't contain control characters. rhriN��!_contains_disallowed_url_pchar_rerkrrl)rGrwrms   rrZzHTTPConnection._validate_path�sr��2�8�8��=�=���	D��C�c�C�C�05���
�
�C�C�C�D�D�
D�	D�	Dr c��t�|��}|r(td|�d|����d����dS)z9Validate a host so it doesn't contain control characters.rorhriNrp)rGrrms   rr
zHTTPConnection._validate_host�sr��2�8�8��>�>���	D��C�d�C�C�05���
�
�C�C�C�D�D�
D�	D�	Dr c��|jtkrt���t|d��r|�d��}t|��st
d|�����t|��}t|��D]�\}}t|d��r|�d��||<n:t|t��r%t|���d��||<t||��rt
d||�������d�
|��}|dz|z}|�|��dS)	zkSend a request header line to the server.

        For example: h.putheader('Accept', 'text/html')
        r(r!zInvalid header name r'zInvalid header value s
	s: N)rrXrr�r(�_is_legal_header_namer�r��	enumerater�r�r|�_is_illegal_header_valuer^rF)rGr,�valuesr��	one_valuer�s      rr]zHTTPConnection.putheader�sU��
�<�?�*�*�"�$�$�$��6�8�$�$�	,��]�]�7�+�+�F�$�V�,�,�	C��*���A�B�B�B��f����%�f�-�-�	K�	K�L�A�y��y�(�+�+�
;�%�,�,�Y�7�7��q�	�	��I�s�+�+�
;��	�N�N�1�1�'�:�:��q�	�'��q�	�2�2�
K� �j�f�Q�i�i�!I�J�J�J�
K����v�&�&���%��%�'�����V�����r �rOc��|jtkr
t|_nt���|�||���dS)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.
        ryN)rrX�_CS_REQ_SENTrrR)rGrNrOs   r�
endheaderszHTTPConnection.endheaderssE���<�?�*�*�'�D�L�L�"�$�$�$����,�~��F�F�F�F�Fr c�8�|�|||||��dS)z&Send a complete request to the server.N)�
_send_request)rGrvrwr�rYrOs      rr`zHTTPConnection.requests&��	
���6�3��g�~�F�F�F�F�Fr c�V�td�|D����}i}d|vrd|d<d|vrd|d<|j||fi|��d|vrzd|vrud	}|�||��}|�8|�5|jd
krt	d|z��d}|�d
d��n&|�dt
|����nd	}|���D]\}	}
|�|	|
���t|t��rt|d��}|�
||���dS)Nc3�>K�|]}|���V��dSr�)rB)r�ks  r�	<genexpr>z/HTTPConnection._send_request.<locals>.<genexpr>s*���� <� <�q������ <� <� <� <� <� <r rrAr^zaccept-encodingr_r�r�FrzUnable to determine size of %rTzTransfer-EncodingrqzContent-Lengthr�ry)�	frozensetrer�rjr}r]r|r�r�r1r|)rGrvrwr�rYrO�header_names�skips�content_lengthr�r�s           rr~zHTTPConnection._send_requests|�� � <� <�G� <� <� <�<�<�����\�!�!�!"�E�+����,�,�,-�E�(�)������-�-�u�-�-�-��<�/�/�#�,�6�6�"'��!%�!9�!9�$��!G�!G��!�)��'��?�Q�.�.�!�"B�T�"I�J�J�J�)-�����':�I�F�F�F���N�N�#3�S��5H�5H�I�I�I��"�N�!�-�-�/�/�	'�	'�J�C���N�N�3��&�&�&�&��d�C� � �	)��4��(�(�D�����^��<�<�<�<�<r c�|�|jr |j���rd|_|jtks|jrt	|j���|jdkr(|�|j|j|j���}n!|�|j|j���}		|�	��n##t$r|����wxYw|jtksJ�t|_|jr|���n||_|S#|����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.
        Nrr#)rr�rr{rrjr&rurkr��ConnectionErrorr�rtrmr)rGr-s  r�getresponsezHTTPConnection.getresponseGsO���?�	#�t��7�7�9�9�	#�"�D�O�"�<�<�'�'�4�?�'�"�4�<�0�0�0��?�Q����*�*�4�9�d�o�26�,�+�@�@�H�H��*�*�4�9�T�\�*�J�J�H�	�
���� � � � ��"�
�
�
��
�
�����
�����&�(�2�2�2�2�#�D�L��"�
+��
�
�����#+����O��	��N�N�������s�)B>�=D$�> C�AD$�$D;)NN)NF)FFr�)&rMrNrOrMr[rr&�	HTTP_PORTrr=rj�staticmethodr�r�r�_GLOBAL_DEFAULT_TIMEOUTrxrrrrr/r+r�r%rFrHrRrer\rYrZr
r]r|r`r~r�rr rrr!s#�������I��M�!�N��L��I��J��1�1��\�1�
����\��>#'��0N� $��;�;�;�;�,)�)�)�)�0���( � � ����
"�"�"�H
�
�
�!�!�!�&G�&G�&G�P������4(�4(�4(�4(�l16�(-�}�}�}�}�~'�'�'�;�;�;�D�D�D�D�D�D����8G�e�G�G�G�G�G�)-�b�G�$�G�G�G�G�G�
,=�,=�,=�\=�=�=�=�=r rc�P��eZdZdZeZdddejdfdddd��fd�Z�fd�Z	�xZ
S)�HTTPSConnectionz(This class allows communication via SSL.Nr�)�context�check_hostnamer�c�2��tt|���|||||	���|�|�|� ddl}
|
�dt
d��||_||_|�Btj	��}|j
dkr|�dg��|j�d|_|j
tjk}|�|j}|r|st!d���|s|r$|�||��|j�d|_||_|�||j_dSdS)	N)r�rzTkey_file, cert_file and check_hostname are deprecated, use a custom context instead.rzr�zhttp/1.1TzMcheck_hostname needs a SSL context with either CERT_OPTIONAL or CERT_REQUIRED)r�r�rx�warnings�warn�DeprecationWarning�key_file�	cert_file�ssl�_create_default_https_contextrM�set_alpn_protocols�post_handshake_auth�verify_mode�	CERT_NONEr�r��load_cert_chain�_context)
rGrr	r�r�r�r�r�r�r�r��will_verifyr�s
            �rrxzHTTPSConnection.__init__�su���
�/�4�(�(�1�1�$��g�2@�<E�
2�
G�
G�
G��$�	�(=�&�2������
�
�J�0�!�5�5�5�%�D�M�&�D�N����;�=�=���>�R�'�'��.�.�
�|�<�<�<��.�:�26�G�/�!�-���>�K��%�!(�!7���
J�k�
J� �"I�J�J�J��
7�9�
7��'�'�	�8�<�<�<��.�:�26�G�/�#�D�M��)�/=��
�,�,�,�*�)r c���t�����|jr|j}n|j}|j�|j|���|_dS)z(Connect to a host on a given (SSL) port.)�server_hostnameN)r�r+rrr��wrap_socketru)rGr�r�s  �rr+zHTTPSConnection.connect�s`���
�G�G�O�O����� �
,�"&�"3���"&�)���
�1�1�$�)�BQ�2�S�S�D�I�I�Ir )rMrNrO�__doc__�
HTTPS_PORTrrr�rxr+r�r�s@rr�r��s��������2�2�!��'+�T�T�#�;�$(�%	>�59�$(�D�%	>�%	>�%	>�%	>�%	>�%	>�%	>�N	S�	S�	S�	S�	S�	S�	S�	S�	Sr r�c��eZdZdS)rN�rMrNrOrr rrr�s������	�Dr rc��eZdZdS)rNr�rr rrr���������Dr rc��eZdZdS)rNr�rr rrr�r�r rc��eZdZd�ZdS)rc�$�|f|_||_dSr�)�argsrn)rGrns  rrxzUnknownProtocol.__init__�s���H��	�����r N�rMrNrOrxrr rrr�s#����������r rc��eZdZdS)r	Nr�rr rr	r	�r�r r	c��eZdZdS)r
Nr�rr rr
r
�r�r r
c�*�eZdZdd�Zd�ZejZdS)rNc�2�|f|_||_||_dSr�)r��partial�expected)rGr�r�s   rrxzIncompleteRead.__init__�s���H��	���� ��
�
�
r c�r�|j�d|jz}nd}d|jjt|j��|fzS)Nz, %i more expectedr{z%s(%i bytes read%s))r�r�rMrCr�r8s  r�__repr__zIncompleteRead.__repr__�sE���=�$�$�t�}�4�A�A��A�$���(?�(+�D�L�(9�(9�1�(>�>�	>r r�)rMrNrOrxr�r+�__str__rr rrr�s:������!�!�!�!�>�>�>��n�G�G�Gr rc��eZdZdS)r
Nr�rr rr
r
�r�r r
c��eZdZdS)rNr�rr rrr�r�r rc��eZdZdS)rNr�rr rrr�r�r rc��eZdZdS)rNr�rr rrr�r�r rc��eZdZd�ZdS)rc�F�|st|��}|f|_||_dSr�)r~r�rKr�s  rrxzBadStatusLine.__init__�s)���	���:�:�D��E��	���	�	�	r Nr�rr rrr�s#����������r rc��eZdZd�ZdS)rc�P�t�|dt|fz��dS)Nz&got more than %d bytes when reading %s)rrxrV)rG�	line_types  rrxzLineTooLong.__init__s6�����t�%M�(0�)�'<�&=�	>�	>�	>�	>�	>r Nr�rr rrr�s#������>�>�>�>�>r rc��eZdZd�ZdS)rc�f�t�|d��tj|g|�Ri|��dS)Nr{)rrx�ConnectionResetError)rG�pos�kws   rrxzRemoteDisconnected.__init__s?�����t�R�(�(�(��%�d�7�S�7�7�7�B�7�7�7�7�7r Nr�rr rrrs#������8�8�8�8�8r r)r%)Er��email.parserr`�
email.messager6r'r��rerr1�collections.abcr?�urllib.parser�__all__r�r�rmrrXr{�globals�updater(�__members__rwrrVrW�compile�	fullmatchrtrkrvrqrjr�r1r�r<r.�Messager>rZre�BufferedIOBaserrr�r�rF�ImportError�	Exceptionrrrrr	r
rr
rrrrrr�rrrr r�<module>r�sC��D�D�L����������������	�	�	�	�	�	�	�	�
�
�
�
�
�
�
�
�����!�!�!�!�!�!�����
�	�
�
�����#������	�	�����,�-�-�-�
H�G�$�/�"=�"D�"D�"F�"F�G�G�G�	�����6#��
�#6�7�7�A��%�2�:�&C�D�D�K��%/�B�J�/@�$A�$A�!�(2�r�z�-�'@�'@�$�3�2�2��E�E�E�E����%����������%�-�'����<���$)�@�@�@�@�i�i�i�i�i�2�$�i�i�i�Vc	�c	�c	�c	�c	�c	�c	�c	�J@&��J�J�J�9S�9S�9S�9S�9S�.�9S�9S�9S�v�N�N�$�%�%�%�%��}�	�	�	��D�	����@	�	�	�	�	�I�	�	�	�
	�	�	�	�	�=�	�	�	�	�	�	�	�	��	�	�	������m����
	�	�	�	�	�m�	�	�	�	�	�	�	�	�M�	�	�	������]����	�	�	�	�	�m�	�	�	�	�	�	�	�	�/�	�	�	�	�	�	�	�	�.�	�	�	�	�	�	�	�	�.�	�	�	������M����>�>�>�>�>�-�>�>�>�
8�8�8�8�8�-�}�8�8�8�	���s�+E�E�E

Zerion Mini Shell 1.0