AlkantarClanX12

Your IP : 18.191.200.114


Current Path : /opt/alt/python311/lib64/python3.11/http/__pycache__/
Upload File :
Current File : //opt/alt/python311/lib64/python3.11/http/__pycache__/client.cpython-311.opt-1.pyc

�

c��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�F�|�d��\}}}|r|dz
}|S)z)Remove interface scope from IPv6 address.�%�])�	partition)r2�percent�_s   r�_strip_ipv6_ifacer:�s3��#�-�-�d�3�3��H�g�q����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__rJrr 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.
    Tr?�header linezgot more than %d headers��
�
r )�readline�_MAXLINErArrD�_MAXHEADERSr)�fp�headersrIs   r�
_read_headersrX�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)rX�join�decode�email�parser�Parser�parsestr)rVr[rW�hstrings    r�
parse_headersrc�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)�makefilerV�
debuglevel�_methodrW�msg�_UNKNOWN�version�status�reason�chunked�
chunk_left�length�
will_close)rE�sockrh�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)Nr?rZzstatus linerzreply:z-Remote end closed connection without response��zHTTP/r!i�)�strrVrSrTrArrh�print�reprr�split�
ValueError�
startswith�_close_connr�int)rErIrlrmrns     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-encodingroF�content-lengthr!���HEAD)rWr��CONTINUErXrVrhr{�coderm�striprnrlrrrcrj�items�getr@rorp�_check_closerrrqr�r~�
NO_CONTENT�NOT_MODIFIEDri)	rErlrmrn�skipped_headers�hdr�val�tr_encrqs	         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)rWr�rlr@)rE�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)rVr�)rErVs  rr�zHTTPResponse._close_conn�s!��
�W�����
���
�
�
�
�
r c����	t�����|jr|���dSdS#|jr|���wwxYwr�)�superr�rVr��rE�	__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��flushrVr�s �rr�zHTTPResponse.flush�s;���
���
�
�����7�	��G�M�M�O�O�O�O�O�	�	r c��dS)zAlways returns TrueTr�rEs r�readablezHTTPResponse.readable�s���tr c��|jduS)z!True if the connection is closed.N)rVr�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)
rVrir�ro�
_read_chunkedrq�readrA�
_safe_readr)rE�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�)	rVrir�ro�_readinto_chunkedrqrA�
memoryview�readinto)rE�brFs   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)Nr?z
chunk size�;r�)	rVrSrTrAr�findr�r~r�)rErI�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)NTr?ztrailer linerP)rVrSrTrAr�rErIs  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)Nrxr r)rpr�r�r~rr�r�)rErps  r�_get_chunk_leftzHTTPResponse._get_chunk_left1s����_�
��	)��%�����"�"�"�
*�!�7�7�9�9�
�
���
*�
*�
*�$�S�)�)�)�
*�����Q����.�.�0�0�0�� � �"�"�"�!�
�(�D�O��s	�7�Ac��g}		|���}|�nr|�9||kr3|�|�|����||z
|_n7|�|�|����|�||z}d|_��d�|��S#t
$r(}td�|����|�d}~wwxYw)NTrr )r�rDr�rpr\r)rEr��valuerp�excs     rr�zHTTPResponse._read_chunkedIs�����	;�

$�!�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�BB#�#
C�-#C�Cc��d}t|��}		|���}|�|St|��|kr$|�|��}||z
|_||zS|d|�}|�|��}||d�}||z
}d|_��#t
$r%tt
|d|������wxYw)Nr)r�r�rA�_safe_readintorpr�bytes)rEr��total_bytes�mvbrprF�temp_mvbs       rr�zHTTPResponse._readinto_chunked_s�������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�#6B�/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.
        )rVr�rAr)rEr�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)rArVr�rr�)rEr�r�rFs    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)rVriro�_read1_chunkedrq�read1r�rA)rErF�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 )rVriro�
_peek_chunked�peek)rErFs  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)rVriror�rSrqr�rA)rE�limitr�r�s   �rrSzHTTPResponse.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�rVr�rprAr)rErFrpr�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�rrVr�)rErFrps   rr�zHTTPResponse._peek_chunked�sf��	��-�-�/�/�J�J���	�	�	��3�3�	�������3��w�|�|�J�'�'����4�4s��
%�%c�4�|j���Sr�)rV�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, )rWr�get_all�
isinstancerz�hasattrr\)rEr/�defaultrWs    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.)rWr�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.

        )rWr�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.

        )rur�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.

        )rmr�s r�getcodezHTTPResponse.getcodes��
�{�r )rNNr�)r�)"rKrLrMrvr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rSr�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.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�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�rzrA)�bodyrt�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�	blocksizers�_buffer�_HTTPConnection__response�_CS_IDLE�_HTTPConnection__stateri�_tunnel_host�_tunnel_port�_tunnel_headers�
_get_hostport�host�port�_validate_host�socket�create_connection�_create_connection)rErrr�r�r�s      rrvzHTTPConnection.__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)rs�RuntimeErrorrrrr�clear)rErrrWs    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>�]r?ryznonnumeric port: '%s'r�[r�)�rfindr�r~�default_portr)rErrr��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�)rh)rE�levels  r�set_debuglevelzHTTPConnection.set_debuglevel�s
������r c�6�d|vr|ddkrd|zdzS|S)N�:r�[�[r6r)rE�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'rQr �rtzTunnel connection failed: � Tr?rOrPrr�)rrr(rrr�rD�sendr\�response_classrsrir��http�
HTTPStatus�OKr��OSErrorr�rVrSrTrArrhr{r])
rE�connectrW�headerr��responserlr��messagerIs
          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.connectr?N)�sys�auditrrrr�r�rs�
setsockoptr
�IPPROTO_TCP�TCP_NODELAYr*�errno�ENOPROTOOPTrr/�rE�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)rrrsr�r)rErsr-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-1r?rZzhttp.client.sendz9data should be a bytes-like object or an iterable, got %r)rs�	auto_openr+rrhr{r|r�r�r�r�r(r1r2�sendallr�r��collections�abc�Iterable�type)rEr%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)r�rD)rEr�s  r�_outputzHTTPConnection._outputs ��
	
����A�����r c#�K�|jdkrtd��|�|��}|r|jdkrtd��	|�|j��}|sdS|r|�d��}|V��:)Nrzreading a readabler<TrZ)rhr{r�r�r�r()rEr�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 rQNr�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��iterrBrhr{�	_http_vsnrAr()rE�message_body�encode_chunkedrj�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�ryr'r!�idna�Hostr>zAccept-Encoding�identity)rr�rr�_CS_REQ_STARTEDr�_validate_methodri�_validate_path�
_http_vsn_strrF�_encode_requestrMrrr(r)�	putheaderr:rrrrrrr])rErtru�	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()rEr`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)rErt�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)rErurms   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)rErrms   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�rz�_is_illegal_header_valuer\rF)rEr,�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)rErNrOs   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)rErtrur�rWrOs      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�)r@)r�ks  r�	<genexpr>z/HTTPConnection._send_request.<locals>.<genexpr>s*���� <� <�q������ <� <� <� <� <� <r rr?r^zaccept-encodingr_r�r�FrzUnable to determine size of %rTzTransfer-EncodingrozContent-Lengthr�ry)�	frozensetrer�rhr{r]rzr�r�r1r|)rErtrur�rWrO�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�X�|jr |j���rd|_|jtks|jrt	|j���|jdkr(|�|j|j|j���}n!|�|j|j���}		|�	��n##t$r|����wxYwt|_|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{rrhr&rsrir��ConnectionErrorr�rrr)rEr-s  r�getresponsezHTTPConnection.getresponseGs;���?�	#�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�	�
���� � � � ��"�
�
�
��
�
�����
����$�D�L��"�
+��
�
�����#+����O��	��N�N�������s�)B>�=D�> C�3D�D))NN)NF)FFr�)&rKrLrMrMr[rr&�	HTTP_PORTrr=rh�staticmethodr�r�r
�_GLOBAL_DEFAULT_TIMEOUTrvrrrrr/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.rxr�zhttp/1.1TzMcheck_hostname needs a SSL context with either CERT_OPTIONAL or CERT_REQUIRED)r�r�rv�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)
rErrr�r�r�r�r�r�r�r��will_verifyr�s
            �rrvzHTTPSConnection.__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_socketrs)rEr�r�s  �rr+zHTTPSConnection.connect�s`���
�G�G�O�O����� �
,�"&�"3���"&�)���
�1�1�$�)�BQ�2�S�S�D�I�I�Ir )rKrLrM�__doc__�
HTTPS_PORTrr
r�rvr+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�rKrLrMrr 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�)�argsrl)rErls  rrvzUnknownProtocol.__init__�s���H��	�����r N�rKrLrMrvrr 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)rEr�r�s   rrvzIncompleteRead.__init__�s���H��	���� ��
�
�
r c�r�|j�d|jz}nd}d|jjt|j��|fzS)Nz, %i more expectedryz%s(%i bytes read%s))r�r�rKrAr�r8s  r�__repr__zIncompleteRead.__repr__�sE���=�$�$�t�}�4�A�A��A�$���(?�(+�D�L�(9�(9�1�(>�>�	>r r�)rKrLrMrvr�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�rIr�s  rrvzBadStatusLine.__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)rrvrT)rE�	line_types  rrvzLineTooLong.__init__s6�����t�%M�(0�)�'<�&=�	>�	>�	>�	>�	>r Nr�rr rrr�s#������>�>�>�>�>r rc��eZdZd�ZdS)rc�f�t�|d��tj|g|�Ri|��dS)Nry)rrv�ConnectionResetError)rE�pos�kws   rrvzRemoteDisconnected.__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��rer
r1�collections.abcr?�urllib.parser�__all__r�r�rkrrXr{�globals�updater(�__members__rwrrTrU�compile�	fullmatchrtrkrvrqrjr�r1r�r:r.�Messager<rXrc�BufferedIOBaserrr�r�rD�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