
    vKgpZ                        S SK r S SKrS SKJr  S SKrS SKJrJr  S SK	J
r
Jr  S SKrS SKJrJrJrJrJrJrJr  S SKJr  \R0                  " \5      r " S S\5      r " S	 S
5      r " S S\\5      r " S S\\5      r " S S\
5      r " S S\5      r  S"S jr!S r"S r# " S S5      r$ " S S5      r% " S S5      r& " S S5      r' " S S5      r( " S  S!\5      r)g)#    N)Mapping)HTTPConnectionVerifiedHTTPSConnection)HTTPConnectionPoolHTTPSConnectionPool)HTTPHeadersHTTPResponseMutableMapping	urlencodeurlparseurlsplit
urlunsplit)UnseekableStreamErrorc                        \ rS rSrS rS rSrg)AWSHTTPResponse%   c                 d    UR                  S5      U l        [        R                  " U /UQ70 UD6  g )Nstatus_tuple)pop_status_tupler	   __init__selfargskwargss      S/var/www/highfloat_scraper/venv/lib/python3.13/site-packages/botocore/awsrequest.pyr   AWSHTTPResponse.__init__(   s+    #ZZ7d4T4V4    c                 r    U R                   b  U R                   nS U l         U$ [        R                  " U 5      $ N)r   r	   _read_status)r   r   s     r   r!   AWSHTTPResponse._read_status,   s8    )--L!%D,,T22r   )r   N)__name__
__module____qualname____firstlineno__r   r!   __static_attributes__ r   r   r   r   %   s    53r   r   c                   |   ^  \ rS rSrSrU 4S jrU 4S jrSU 4S jjrS rSS jr	S r
S	 rS
 rU 4S jrS rSrU =r$ )AWSConnection5   a  Mixin for HTTPConnection that supports Expect 100-continue.

This when mixed with a subclass of httplib.HTTPConnection (though
technically we subclass from urllib3, which subclasses
httplib.HTTPConnection) and we only override this class to support Expect
100-continue, which we need for S3.  As far as I can tell, this is
general purpose enough to not be specific to S3, but I'm being
tentative and keeping it in botocore because I've only tested
this against AWS services.

c                 r   > [         TU ]  " U0 UD6  U R                  U l        SU l        SU l        SU l        g NF)superr   response_class_original_response_cls_response_received_expect_header_set_send_called)r   r   r   	__class__s      r   r   AWSConnection.__init__B   s=    $)&)&*&9&9# #("'!r   c                 n   > [         TU ]  5         SU l        SU l        SU l        U R
                  U l        g r-   )r.   closer1   r2   r3   r0   r/   )r   r4   s    r   r7   AWSConnection.closeO   s2    "'"'!"99r   c                    > Uc  0 nSU l         UR                  SS5      S:X  a  SU l        OSU l        U R                  U l        [
        TU ]  " XX4/UQ70 UD6nSU l        U$ )NFExpectr   s   100-continueT)r1   getr2   r0   r/   r.   request)	r   methodurlbodyheadersr   r   rvalr4   s	           r   r<   AWSConnection.requestW   sm    ?G"';;x%8&*D#&+D#"&"="=DwvDKDKFK"'r   c                     / nU HK  n[        U[        5      (       a"  UR                  UR                  S5      5        M:  UR                  U5        MM     SR	                  U5      nU$ )Nutf-8   
)
isinstancestrappendencodejoin)r   mixed_bufferbytes_bufferchunkmsgs        r   _convert_to_bytesAWSConnection._convert_to_bytesd   sZ     !E%%%##ELL$9:##E*	 "
 ll<(
r   c                    U R                   R                  S5        U R                  U R                   5      nU R                   S S 2	 [        U[        5      (       a  XA-  nS nU R                  U5        U R                  (       ak  [        R                  S5        [        R                  R                  U R                  S5      (       a  U R                  U5        g [        R                  S5        Ub  U R                  U5        g g )N)r   r   z"Waiting for 100 Continue response.   zCNo response seen from server, continuing to send the response body.)_bufferextendrO   rF   bytessendr2   loggerdebugurllib3utilwait_for_readsock_handle_expect_response)r   message_bodyr   r   rN   s        r   _send_outputAWSConnection._send_outputq   s    J'$$T\\2LLO lE**CL		#"" LL=>||))$))Q77,,\: . # IIl# $r   c                 F    S nUS:w  a  UR                  5       nUS:w  a  M  g g )NrE   )readline)r   fpcurrents      r   _consume_headersAWSConnection._consume_headers   s&      kkmG  r   c                    U R                   R                  SS5      n UR                  5       nUR                  S S5      nU R	                  U5      (       a8  U R                  U5        [        R                  S5        U R                  U5        O[        U5      S:X  a  US   R                  S5      (       ap  [        R                  S5        US   R                  S5      [        US	   5      US   R                  S5      4n[        R                  " [        US
9nX`l        SU l        UR%                  5         g ! UR%                  5         f = f)Nrbr      z5100 Continue response seen, now sending request body.      HTTP/zOReceived a non 100 Continue response from the server, NOT sending request body.asciirR   )r   T)r\   makefilerb   split_is_100_continue_statusre   rW   rX   _send_message_bodylen
startswithdecodeint	functoolspartialr   r/   r1   r7   )r   r^   rc   maybe_status_linepartsr   r/   s          r   r]   %AWSConnection._handle_expect_response   s    YYa(%	 "%++D!4E++,=>>%%b)K ''5UqU1X%8%8%B%B A
 !HOOG,aM!HOOG, 
 "+!2!2#," '5#*.'HHJBHHJs   DD7 7E	c                 .    Ub  U R                  U5        g g r    )rV   )r   r^   s     r   rp    AWSConnection._send_message_body   s    #IIl# $r   c                    > U R                   (       a.  U R                  (       d  [        R                  S5        SU l        g [        TU ]  U5      $ )Nz?send() called, but response already received. Not sending data.T)r1   r3   rW   rX   r.   rV   )r   rG   r4   s     r   rV   AWSConnection.send   sD    ""$$ ( !%Dw|C  r   c                     UR                  S S5      n[        U5      S:  =(       a#    US   R                  S5      =(       a    US   S:H  $ )Nri   rj   r   rk   rR   s   100)rn   rq   rr   )r   rw   rx   s      r   ro   %AWSConnection._is_100_continue_status   sN    !''a0 J!O #a##H-#aF"	
r   )r2   r0   r1   r3   r/   NNr    )r#   r$   r%   r&   __doc__r   r7   r<   rO   r_   re   r]   rp   rV   ro   r'   __classcell__)r4   s   @r   r*   r*   5   sA    
":$$L
$*X$!
 
r   r*   c                       \ rS rSrSrSrg)AWSHTTPConnection   z6An HTTPConnection that supports 100 Continue behavior.r(   Nr#   r$   r%   r&   r   r'   r(   r   r   r   r      s    @r   r   c                       \ rS rSrSrSrg)AWSHTTPSConnection   z7An HTTPSConnection that supports 100 Continue behavior.r(   Nr   r(   r   r   r   r      s    Ar   r   c                       \ rS rSr\rSrg)AWSHTTPConnectionPool   r(   N)r#   r$   r%   r&   r   ConnectionClsr'   r(   r   r   r   r      s    %Mr   r   c                       \ rS rSr\rSrg)AWSHTTPSConnectionPool   r(   N)r#   r$   r%   r&   r   r   r'   r(   r   r   r   r      s    &Mr   r   c                    U nUb	  US   nX5S'   UR                  S5      n[        XS   U5      nUS   (       a<  [        R                  R                  nU" US   5      n	SU;  a	  USU	 3-  nOUSU	 3-  nXtS	'   X$S
'   Uc  0 US
'   gg)a  
This method prepares a request dict to be created into an
AWSRequestObject. This prepares the request dict by adding the
url and the user agent to the request dict.

:type request_dict: dict
:param request_dict:  The request dict (created from the
    ``serialize`` module).

:type user_agent: string
:param user_agent: The user agent to use for this request.

:type endpoint_url: string
:param endpoint_url: The full endpoint url, which contains at least
    the scheme, the hostname, and optionally any path components.
Nr@   z
User-Agenthost_prefixurl_pathquery_string?&r>   context)r;   _urljoinbotocoreutilspercent_encode_sequence)
request_dictendpoint_urlr   
user_agentrr@   r   r>   r   encoded_query_strings
             r   prepare_request_dictr      s    & 	AI, *%%&K
<:
<C #+.."H"H6q7HIc>Q+,--CQ+,--CeHiL) r   c           	      n    U n[        US   US   US   US   UR                  S5      S9nUS   Ul        U$ )a+  
This method takes a request dict and creates an AWSRequest object
from it.

:type request_dict: dict
:param request_dict:  The request dict (created from the
    ``prepare_request_dict`` method).

:rtype: ``botocore.awsrequest.AWSRequest``
:return: An AWSRequest object based on the request_dict.

r=   r>   r?   r@   	auth_path)r=   r>   datar@   r   r   )
AWSRequestr;   r   )r   r   request_objects      r   create_request_objectr   $  sO     	A{eHvY)%%$N y\Nr   c                 *   [        U 5      nU(       a  US:X  a  US   (       d  SnOIUS   nOCUS   R                  S5      (       a"  UR                  S5      (       a  US   S S U-   nOUS   U-   nUS   nUb  X%-   n[        US   XTUS   US   45      nU$ )N/ri   rR   r   rj      )r   endswithrr   r   )r   r   r   pnew_path
new_netlocreconstructeds          r   r   r   =  s    A x3 tHtH	
1s		 3 3C 8 8Q49x'Q4(?1J -
!jAaD!A$GHMr   c                   @    \ rS rSrSrS rS rSS jrS rS r	S	 r
S
rg)AWSRequestPrepareriY  a  
This class performs preparation on AWSRequest objects similar to that of
the PreparedRequest class does in the requests library. However, the logic
has been boiled down to meet the specific use cases in botocore. Of note
there are the following differences:
    This class does not heavily prepare the URL. Requests performed many
    validations and corrections to ensure the URL is properly formatted.
    Botocore either performs these validations elsewhere or otherwise
    consistently provides well formatted URLs.

    This class does not heavily prepare the body. Body preperation is
    simple and supports only the cases that we document: bytes and
    file-like objects to determine the content-length. This will also
    additionally prepare a body that is a dict to be url encoded params
    string as some signers rely on this. Finally, this class does not
    support multipart file uploads.

    This class does not prepare the method, auth or cookies.
c                     UR                   nU R                  U5      nU R                  U5      nU R                  X5      nUR                  n[        X#XTU5      $ r    )r=   _prepare_url_prepare_body_prepare_headersstream_outputAWSPreparedRequest)r   originalr=   r>   r?   r@   r   s          r   prepareAWSRequestPreparer.preparen  sU    )!!(+''7 ..!&wmLLr   c                 V   UR                   nUR                  (       a  [        U5      nUR                  (       a  SOSn[	        UR                  [
        5      (       a$  [        UR                  R                  5       5      nOUR                  n[        USS9nUR                  X&45      nU$ )Nr   r   Tdoseq)
r>   paramsr   queryrF   r   listitemsr   rJ   )r   r   r>   	url_partsdelimparams_to_encoder   s          r   r   AWSRequestPreparer._prepare_urlw  s}    ll?? I$??CE(//733#'(=(=(?#@ #+?? /t<F**c]+C
r   Nc                    [        UR                  R                  5       5      nSU;   d  SU;   a  U$ UR                  S;  aJ  U R	                  U5      nUb  [        U5      US'   U$ [        U5      n[        R                  SU5        SUS'   U$ )NzTransfer-EncodingzContent-Length)GETHEADOPTIONSz Failed to determine length of %schunked)	HeadersDictr@   r   r=   _determine_content_lengthrG   typerW   rX   )r   r   prepared_bodyr@   length	body_types         r   r   #AWSRequestPreparer._prepare_headers  s    h..4467 ')-=-HN ??"<<33MBF!,/K() 	 !/	?K/8+,r   c                     Uu  p#[        U[        5      (       a  UR                  S5      n[        U[        5      (       a  UR                  S5      nX#4$ NrD   )rF   rG   rI   )r   itemkeyvalues       r   _to_utf8AWSRequestPreparer._to_utf8  sG    
c3**W%CeS!!LL)Ezr   c                     UR                   nUS:X  a  Sn[        U[        5      (       a7  UR                  5        Vs/ sH  o0R	                  U5      PM     nn[        USS9nU$ s  snf )z"Prepares the given HTTP body data.r   NTr   )r   rF   dictr   r   r   )r   r   r?   r   r   s        r   r    AWSRequestPreparer._prepare_body  s\    }}3;DdD!!6:jjlCldmmD)lFCV40D Ds   A#c                 @    [         R                  R                  U5      $ r    )r   r   determine_content_lengthr   r?   s     r   r   ,AWSRequestPreparer._determine_content_length  s    ~~66t<<r   r(   r    )r#   r$   r%   r&   r   r   r   r   r   r   r   r'   r(   r   r   r   r   Y  s&    (M*
=r   r   c                   J    \ rS rSrSr\r       SS jrS r\	S 5       r
Srg)	r   i  zRepresents the elements of an HTTP request.

This class was originally inspired by requests.models.Request, but has been
boiled down to meet the specific use cases in botocore. That being said this
class (even in requests) is effectively a named-tuple.
Nc                    U R                  5       U l        Uc  0 OUnXl        X l        [	        5       U l        X@l        XPl        X`l        Xpl	        Ub'  UR                  5        H  u  pXR
                  U'   M     0 U l        g r    )_REQUEST_PREPARER_CLS_request_preparerr=   r>   r   r@   r   r   r   r   r   r   )
r   r=   r>   r@   r   r   r   r   r   r   s
             r   r   AWSRequest.__init__  sw     "&!;!;!= ~6"}	"*%mmo
$)S! . r   c                 8    U R                   R                  U 5      $ )z>Constructs a :class:`AWSPreparedRequest <AWSPreparedRequest>`.)r   r   r   s    r   r   AWSRequest.prepare  s    %%--d33r   c                     U R                  5       R                  n[        U[        5      (       a  UR	                  S5      nU$ r   )r   r?   rF   rG   rI   r   s     r   r?   AWSRequest.body  s3    ||~""dC  ;;w'Dr   )	r   r   r   r   r@   r=   r   r   r>   )NNNNNNF)r#   r$   r%   r&   r   r   r   r   r   propertyr?   r'   r(   r   r   r   r     sE     / "H4  r   r   c                   *    \ rS rSrSrS rS rS rSrg)r   i  a{  A data class representing a finalized request to be sent over the wire.

Requests at this stage should be treated as final, and the properties of
the request should not be modified.

:ivar method: The HTTP Method
:ivar url: The full url
:ivar headers: The HTTP headers to send.
:ivar body: The HTTP body.
:ivar stream_output: If the response for this request should be streamed.
c                 @    Xl         X l        X0l        X@l        XPl        g r    )r=   r>   r@   r?   r   )r   r=   r>   r@   r?   r   s         r   r   AWSPreparedRequest.__init__  s    	*r   c                 f    SnXR                   U R                  U R                  U R                  4-  $ )NzD<AWSPreparedRequest stream_output=%s, method=%s, url=%s, headers=%s>)r   r=   r>   r@   )r   fmts     r   __repr__AWSPreparedRequest.__repr__  s2     	 (($++txxNNNr   c                 f   [         [        [        4nU R                  b  [	        U R                  U5      (       a  g [
        R                  SU R                  5        U R                  R                  S5        g! [         a.  n[
        R                  SU5        [        U R                  S9eSnAff = f)a  Resets the streaming body to it's initial position.

If the request contains a streaming body (a streamable file-like object)
seek to the object's initial position to ensure the entire contents of
the object is sent. This is a no-op for static bytes-like body types.
NzRewinding stream: %sr   zUnable to rewind stream: %s)stream_object)
rU   rG   	bytearrayr?   rF   rW   rX   seek	Exceptionr   )r   non_seekable_typeses      r   reset_streamAWSPreparedRequest.reset_stream  s     $S)499
4996H I I	ALL/;IINN1 	ALL6:'dii@@	As   ;A8 8
B0)B++B0)r?   r@   r=   r   r>   N)	r#   r$   r%   r&   r   r   r   r   r'   r(   r   r   r   r     s    
+OAr   r   c                   >    \ rS rSrSrS r\S 5       r\S 5       rSr	g)AWSResponsei  a  A data class representing an HTTP response.

This class was originally inspired by requests.models.Response, but has
been boiled down to meet the specific use cases in botocore. This has
effectively been reduced to a named tuple.

:ivar url: The full url.
:ivar status_code: The status code of the HTTP response.
:ivar headers: The HTTP headers received.
:ivar body: The HTTP response body.
c                 V    Xl         X l        [        U5      U l        X@l        S U l        g r    )r>   status_coder   r@   raw_content)r   r>   r   r@   r   s        r   r   AWSResponse.__init__+  s%    &"7+r   c                     U R                   c7  SR                  U R                  R                  5       5      =(       d    SU l         U R                   $ )z!Content of the response as bytes.r   )r  rJ   r   streamr   s    r   contentAWSResponse.content3  s:     == 
  HHTXX__%67>3DM}}r   c                     [         R                  R                  U R                  5      nU(       a  U R                  R                  U5      $ U R                  R                  S5      $ )zContent of the response as a proper text type.

Uses the encoding type provided in the reponse headers to decode the
response content into a proper text type. If the encoding is not
present in the headers, UTF-8 is used as a default.
rD   )r   r   get_encoding_from_headersr@   r  rs   )r   encodings     r   textAWSResponse.text@  sI     >>;;DLLI<<&&x00<<&&w//r   )r  r@   r   r   r>   N)
r#   r$   r%   r&   r   r   r   r  r
  r'   r(   r   r   r   r     s4    
 
 
 0 0r   r   c                   2    \ rS rSrS rS rS rS rS rSr	g)	
_HeaderKeyiO  c                 :    Xl         UR                  5       U l        g r    )_keylower_lowerr   r   s     r   r   _HeaderKey.__init__P  s    	iikr   c                 ,    [        U R                  5      $ r    )hashr  r   s    r   __hash___HeaderKey.__hash__T  s    DKK  r   c                 b    [        U[        5      =(       a    U R                  UR                  :H  $ r    )rF   r  r  )r   others     r   __eq___HeaderKey.__eq__W  s!    %,L1LLr   c                     U R                   $ r    )r  r   s    r   __str___HeaderKey.__str__Z  s    yyr   c                 ,    [        U R                  5      $ r    )reprr  r   s    r   r   _HeaderKey.__repr__]  s    DIIr   )r  r  N)
r#   r$   r%   r&   r   r  r  r  r   r'   r(   r   r   r  r  O  s    "!Mr   r  c                   H    \ rS rSrSrS rS rS rS rS r	S r
S	 rS
 rSrg)r   ia  z9A case-insenseitive dictionary to represent HTTP headers.c                 6    0 U l         U R                  " U0 UD6  g r    )_dictupdater   s      r   r   HeadersDict.__init__d  s    
T$V$r   c                 2    X R                   [        U5      '   g r    r$  r  )r   r   r   s      r   __setitem__HeadersDict.__setitem__h  s    &+

:c?#r   c                 2    U R                   [        U5         $ r    r(  r  s     r   __getitem__HeadersDict.__getitem__k  s    zz*S/**r   c                 0    U R                   [        U5      	 g r    r(  r  s     r   __delitem__HeadersDict.__delitem__n  s    JJz#'r   c                 (    S U R                    5       $ )Nc              3   6   #    U H  n[        U5      v   M     g 7fr    )rG   ).0r   s     r   	<genexpr>'HeadersDict.__iter__.<locals>.<genexpr>r  s     /JSCJs   r$  r   s    r   __iter__HeadersDict.__iter__q  s    /DJJ//r   c                 ,    [        U R                  5      $ r    )rq   r$  r   s    r   __len__HeadersDict.__len__t  s    4::r   c                 ,    [        U R                  5      $ r    )r   r$  r   s    r   r   HeadersDict.__repr__w  s    DJJr   c                 4    [        U R                  5       5      $ r    )r   r   r   s    r   copyHeadersDict.copyz  s    4::<((r   r6  N)r#   r$   r%   r&   r   r   r)  r,  r/  r7  r:  r   r?  r'   r(   r   r   r   r   a  s-    C%,+(0 )r   r   r   )*ru   loggingcollections.abcr   urllib3.utilrY   urllib3.connectionr   r   urllib3.connectionpoolr   r   botocore.utilsr   botocore.compatr   r	   r
   r   r   r   r   botocore.exceptionsr   	getLoggerr#   rW   r   r*   r   r   r   r   r   r   r   r   r   r   r   r  r   r(   r   r   <module>rJ     s      #  F J    6			8	$3l 3 s
 s
lA~ AB(? B&. &'0 '
 :>&R28U= U=p7 7t0A 0Af.0 .0b $). )r   