ó
    äd8h;B  ã                  óâ   • S SK Jr  S SKrS SKrS SKrS SKrSSKJr  SSKJ	r	J
r
  SSKJrJr  SSKJrJrJrJr  SSKJrJrJr  S	S
KJr  S	SKJrJr   " S S5      r " S S\5      r " S S5      rg)é    )ÚannotationsNé   )ÚSyncBackend)ÚSOCKET_OPTIONÚNetworkBackend)ÚConnectionNotAvailableÚUnsupportedProtocol)ÚOriginÚProxyÚRequestÚResponse)ÚEventÚShieldCancellationÚ
ThreadLocké   )ÚHTTPConnection)ÚConnectionInterfaceÚRequestInterfacec                  óR   • \ rS rSrS	S jrS
S jrSS jr S   SS jjrSS jrSr	g)ÚPoolRequesté   c                ó<   • Xl         S U l        [        5       U l        g ©N)ÚrequestÚ
connectionr   Ú_connection_acquired)Úselfr   s     Ú3Lib\site-packages\httpcore\_sync\connection_pool.pyÚ__init__ÚPoolRequest.__init__   s   € ØŒØ6:ˆŒÜ$)£GˆÕ!ó    c                óD   • Xl         U R                  R                  5         g r   )r   r   Úset)r   r   s     r   Úassign_to_connectionÚ PoolRequest.assign_to_connection   s   € Ø$ŒØ×!Ñ!×%Ñ%Õ'r!   c                ó0   • S U l         [        5       U l        g r   )r   r   r   ©r   s    r   Úclear_connectionÚPoolRequest.clear_connection   s   € ØˆŒÜ$)£GˆÕ!r!   Nc                ó„   • U R                   c  U R                  R                  US9  U R                   c   eU R                   $ )N©Útimeout)r   r   Úwait)r   r,   s     r   Úwait_for_connectionÚPoolRequest.wait_for_connection   s?   € ð �?‰?Ñ"Ø×%Ñ%×*Ñ*°7Ð*Ñ;Ø�‰Ñ*Ð*Ð*Ø�‰Ðr!   c                ó   • U R                   S L $ r   )r   r'   s    r   Ú	is_queuedÚPoolRequest.is_queued'   s   € Ø�‰ $Ð&Ð&r!   )r   r   r   )r   r   ÚreturnÚNone)r   zConnectionInterface | Noner3   r4   ©r3   r4   r   )r,   úfloat | Noner3   r   )r3   Úbool)
Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__r   r$   r(   r.   r1   Ú__static_attributes__© r!   r   r   r      s0   † ô,ô
(ô,ð
 '+ðØ#ðà	õ÷'r!   r   c                  óì   • \ rS rSrSr            S                         SS jjrSS jr\SS j5       rSS jr	SS jr
SS	 jrSS
 jrSS jr   S       SS jjrSS jrSrg)ÚConnectionPoolé+   z-
A connection pool for making HTTP requests.
Nc                ó„  • Xl         X l        Uc  [        R                  OUU l        Uc  [        R                  OUU l        [        U R                  U R
                  5      U l        XPl        X`l        Xpl	        X€l
        X�l        X l        Uc
  [        5       OUU l        XÀl        / U l        / U l        [%        5       U l        g)aC  
A connection pool for making HTTP requests.

Parameters:
    ssl_context: An SSL context to use for verifying connections.
        If not specified, the default `httpcore.default_ssl_context()`
        will be used.
    max_connections: The maximum number of concurrent HTTP connections that
        the pool should allow. Any attempt to send a request on a pool that
        would exceed this amount will block until a connection is available.
    max_keepalive_connections: The maximum number of idle HTTP connections
        that will be maintained in the pool.
    keepalive_expiry: The duration in seconds that an idle HTTP connection
        may be maintained for before being expired from the pool.
    http1: A boolean indicating if HTTP/1.1 requests should be supported
        by the connection pool. Defaults to True.
    http2: A boolean indicating if HTTP/2 requests should be supported by
        the connection pool. Defaults to False.
    retries: The maximum number of retries when trying to establish a
        connection.
    local_address: Local address to connect from. Can also be used to connect
        using a particular address family. Using `local_address="0.0.0.0"`
        will connect using an `AF_INET` address (IPv4), while using
        `local_address="::"` will connect using an `AF_INET6` address (IPv6).
    uds: Path to a Unix Domain Socket to use instead of TCP sockets.
    network_backend: A backend instance to use for handling network I/O.
    socket_options: Socket options that have to be included
     in the TCP socket when the connection was established.
N)Ú_ssl_contextÚ_proxyÚsysÚmaxsizeÚ_max_connectionsÚ_max_keepalive_connectionsÚminÚ_keepalive_expiryÚ_http1Ú_http2Ú_retriesÚ_local_addressÚ_udsr   Ú_network_backendÚ_socket_optionsÚ_connectionsÚ	_requestsr   Ú_optional_thread_lock)r   Ússl_contextÚproxyÚmax_connectionsÚmax_keepalive_connectionsÚkeepalive_expiryÚhttp1Úhttp2ÚretriesÚlocal_addressÚudsÚnetwork_backendÚsocket_optionss                r   r   ÚConnectionPool.__init__0   s¿   € ðX (ÔØŒà*Ñ2ŒC�KŠK¸ð 	Ôð
 )Ñ0ô �KŠKà*ð 	Ô'ô
 +.Ø×!Ñ! 4×#BÑ#Bó+
ˆÔ'ð "2ÔØŒØŒØŒØ+ÔØŒ	ð -Ñ4ŒKŒM¸/ð 	Ôð  .Ôð 8:ˆÔØ,.ˆŒô
 &0£\ˆÕ"r!   c                ó:  • U R                   Gb¢  U R                   R                  R                  S;   aw  SSKJn  U" U R                   R                  R
                  U R                   R                  UU R                  U R                  U R                  U R                  U R                  S9$ UR                  S:X  ak  SSKJn  U" U R                   R                  R
                  U R                   R                  U R                   R                  UU R                  U R                  S9$ SSKJn  U" U R                   R                  R
                  U R                   R                  U R                   R                  UU R                  U R                  U R                  U R                  U R                  S	9	$ [#        UU R                  U R                  U R                  U R                  U R$                  U R&                  U R(                  U R                  U R*                  S
9
$ )N)s   socks5s   socks5hr   )ÚSocks5Connection)Úproxy_originÚ
proxy_authÚremote_originrT   rX   rY   rZ   r^   s   http)ÚForwardHTTPConnection)rc   Úproxy_headersÚproxy_ssl_contextre   rX   r^   )ÚTunnelHTTPConnection)	rc   rg   rh   re   rT   rX   rY   rZ   r^   )
ÚoriginrT   rX   rY   rZ   r[   r\   r]   r^   r_   )rC   ÚurlÚschemeÚsocks_proxyrb   rj   ÚauthrB   rI   rJ   rK   rO   Ú
http_proxyrf   ÚheadersrT   ri   r   rL   rM   rN   rP   )r   rj   rb   rf   ri   s        r   Úcreate_connectionÚ ConnectionPool.create_connection€   sŸ  € Ø�;‰;Ò"Ø�{‰{�‰×%Ñ%Ð)@Ó@Ý9á'Ø!%§¡§¡×!7Ñ!7Ø#Ÿ{™{×/Ñ/Ø"(Ø $× 1Ñ 1Ø%)×%;Ñ%;ØŸ+™+ØŸ+™+Ø$(×$9Ñ$9ñ	ð 	ð —‘ 'Ó)Ý=á,Ø!%§¡§¡×!7Ñ!7Ø"&§+¡+×"5Ñ"5Ø&*§k¡k×&=Ñ&=Ø"(Ø%)×%;Ñ%;Ø$(×$9Ñ$9ñð õ 9á'Ø!Ÿ[™[Ÿ_™_×3Ñ3Ø"Ÿk™k×1Ñ1Ø"&§+¡+×"9Ñ"9Ø$Ø ×-Ñ-Ø!%×!7Ñ!7Ø—k‘kØ—k‘kØ $× 5Ñ 5ñ
ð 
ô ØØ×)Ñ)Ø!×3Ñ3Ø—+‘+Ø—+‘+Ø—M‘MØ×-Ñ-Ø—	‘	Ø ×1Ñ1Ø×/Ñ/ñ
ð 	
r!   c                ó,   • [        U R                  5      $ )al  
Return a list of the connections currently in the pool.

For example:

```python
>>> pool.connections
[
    <HTTPConnection ['https://example.com:443', HTTP/1.1, ACTIVE, Request Count: 6]>,
    <HTTPConnection ['https://example.com:443', HTTP/1.1, IDLE, Request Count: 9]> ,
    <HTTPConnection ['http://example.com:80', HTTP/1.1, IDLE, Request Count: 1]>,
]
```
)ÚlistrQ   r'   s    r   ÚconnectionsÚConnectionPool.connectionsµ   s   € ô  �D×%Ñ%Ó&Ð&r!   c           
     óx  • UR                   R                  R                  5       nUS:X  a  [        S5      eUS;  a  [        SU S35      eUR                  R                  S0 5      nUR                  SS5      nU R                     [        U5      nU R                  R                  U5        SSS5          U R                     U R                  5       nSSS5        U R                  W5        WR                  US	9n UR                  UR                  5      n ['        UR(                  [*        R,                  5      (       d   e[/        UR0                  UR2                  [5        UR(                  XPS
9UR                  S9$ ! , (       d  f       NÙ= f! , (       d  f       NÃ= f! [         a    UR!                  5          Of = fGM  ! ["         ak  n	U R                     U R                  R%                  W5        U R                  5       nSSS5        O! , (       d  f       O= fU R                  W5        U	SeSn	A	ff = f)z‰
Send an HTTP request, and return an HTTP response.

This is the core implementation that is called into by `.request()` or `.stream()`.
Ú z;Request URL is missing an 'http://' or 'https://' protocol.)ÚhttpÚhttpsÚwsÚwssz)Request URL has an unsupported protocol 'z://'.r,   ÚpoolNr+   )ÚstreamÚpool_requestr}   )Ústatusrp   ÚcontentÚ
extensions)rk   rl   Údecoder	   r‚   ÚgetrS   r   rR   ÚappendÚ_assign_requests_to_connectionsÚ_close_connectionsr.   Úhandle_requestr   r   r(   ÚBaseExceptionÚremoveÚ
isinstancer~   ÚtypingÚIterabler   r€   rp   ÚPoolByteStream)
r   r   rl   Útimeoutsr,   r   Úclosingr   ÚresponseÚexcs
             r   rˆ   ÚConnectionPool.handle_requestÇ   s  € ð —‘×#Ñ#×*Ñ*Ó,ˆØ�R‹<Ü%ØMóð ð Ð7Ó7Ü%Ø;¸F¸8À5ÐIóð ð ×%Ñ%×)Ñ)¨)°RÓ8ˆØ—,‘,˜v tÓ,ˆà×'Ó'ä& wÓ/ˆLØ�N‰N×!Ñ! ,Ô/÷ (ð
!	 ØØ×/Ó/ð #×BÑBÓD�G÷ 0ð ×'Ñ'¨Ô0ð *×=Ñ=ÀgÐ=ÐN�
ðà)×8Ñ8Ø$×,Ñ,ó �Hð ô ˜(Ÿ/™/¬6¯?©?×;Ñ;Ð;Ð;ÜØ—?‘?Ø×$Ñ$Ü"Ø—‘°\ñð  ×*Ñ*ñ
ð 	
÷W (Õ'ú÷ 0Õ/ûô .ó 4ð
 !×1Ñ1Ö3ð4úò øô0 ó 	 Ø×+Ó+ð —‘×%Ñ% lÔ3Ø×>Ñ>Ó@�÷	 ,×+Ö+úð ×#Ñ# GÔ,Ø˜4Ðûð	 úsr   Â'E?Â5G ÃFÃ(G Ã<F! Å?
FÆ
FÆG Æ!F>Æ;G Æ=F>Æ>G Ç
H9ÇH4Ç,HÈ	H4È
H	ÈH4È4H9c                ó
  • / n[        U R                  5       Hÿ  nUR                  5       (       a  U R                  R                  U5        M5  UR	                  5       (       a.  U R                  R                  U5        UR                  U5        Mx  UR                  5       (       d  M�  [        U R                   Vs/ s H  o"R                  5       PM     sn5      U R                  :”  d  MÒ  U R                  R                  W5        UR                  U5        GM     U R                   Vs/ s H  o3R                  5       (       d  M  UPM     nnU GH›  nUR                  R                  R                  nU R                   Vs/ s H4  nUR                  U5      (       d  M  UR                  5       (       d  M2  UPM6     nnU R                   Vs/ s H  o"R                  5       (       d  M  UPM     nnU(       a  US   nUR!                  U5        MÀ  [        U R                  5      U R"                  :  a@  U R%                  U5      nU R                  R                  U5        UR!                  U5        GM#  U(       d  GM-  US   nU R                  R                  U5        UR                  U5        U R%                  U5      nU R                  R                  U5        UR!                  U5        GMž     U$ s  snf s  snf s  snf s  snf )a  
Manage the state of the connection pool, assigning incoming
requests to connections as available.

Called whenever a new request is added or removed from the pool.

Any closing connections are returned, allowing the I/O for closing
those connections to be handled seperately.
r   )rt   rQ   Ú	is_closedrŠ   Úhas_expiredr…   Úis_idleÚlenrG   rR   r1   r   rk   rj   Úcan_handle_requestÚis_availabler$   rF   rq   )	r   Úclosing_connectionsr   r   Úqueued_requestsr   rj   Úavailable_connectionsÚidle_connectionss	            r   r†   Ú.ConnectionPool._assign_requests_to_connections  s‚  € ð !Ðô ˜t×0Ñ0Ö1ˆJØ×#Ñ#×%Ñ%à×!Ñ!×(Ñ(¨Ö4Ø×'Ñ'×)Ñ)à×!Ñ!×(Ñ(¨Ô4Ø#×*Ñ*¨:Ö6à×"Ñ"×$Ó$ÜÀ×@QÒ@QÓRÒ@Q°*×+Ñ+Ö-Ñ@QÑRÓSØ×1Ñ1õ2ð ×!Ñ!×(Ñ(¨Ô4Ø#×*Ñ*¨:×6ñ 2ð$ 37·.².ÓX². w×DUÑDU×DWŸ7±.ˆÐXÜ+ˆLØ!×)Ñ)×-Ñ-×4Ñ4ˆFð #'×"3Ò"3ó%â"3�JØ×0Ñ0°×8ó à=G×=TÑ=T×=V÷ Ù"3ð "ð %ð .2×->Ò->ó Ú->˜z×BTÑBT×BV—
Ñ->ð ð  ö %à2°1Ñ5�
Ø×1Ñ1°*Ö=Ü�T×&Ñ&Ó'¨$×*?Ñ*?Ó?à!×3Ñ3°FÓ;�
Ø×!Ñ!×(Ñ(¨Ô4Ø×1Ñ1°*×=ß!Ñ!à-¨aÑ0�
Ø×!Ñ!×(Ñ(¨Ô4Ø#×*Ñ*¨:Ô6à!×3Ñ3°FÓ;�
Ø×!Ñ!×(Ñ(¨Ô4Ø×1Ñ1°*×=ñE ,ðH #Ð"ùò[ Sùò Yùò%ùò
 s0   Â:K1
Ä)K6ÅK6ÆK;ÆK;Æ6K;ÇL Ç(L c                ó~   • [        5          U H  nUR                  5         M     S S S 5        g ! , (       d  f       g = fr   )r   Úclose)r   r�   r   s      r   r‡   Ú!ConnectionPool._close_connectionsU  s*   € äÕ!Û%�
Ø× Ñ Ö"ñ &÷ "×!Ö!ús   ‹.®
<c                óª   • U R                      [        U R                  5      n/ U l        S S S 5        U R                  W5        g ! , (       d  f       N = fr   )rS   rt   rQ   r‡   )r   r›   s     r   r¡   ÚConnectionPool.close[  sE   € ð ×'Ó'Ü"& t×'8Ñ'8Ó"9ÐØ "ˆDÔ÷ (ð 	×ÑÐ 3Õ4÷ (Õ'ús   �AÁ
Ac                ó   • U $ r   r=   r'   s    r   Ú	__enter__ÚConnectionPool.__enter__c  s   € Øˆr!   c                ó$   • U R                  5         g r   )r¡   )r   Úexc_typeÚ	exc_valueÚ	tracebacks       r   Ú__exit__ÚConnectionPool.__exit__f  s   € ð 	�
‰
�r!   c                óö  • U R                   R                  nU R                     U R                   Vs/ s H  o"R	                  5       PM     nnU R
                   Vs/ s H  oDR                  5       PM     nnUR                  S5      nUR                  S5      nUR                  S5      nUR                  S5      n	S S S 5        SW SW S3n
SW SW	 S3nSU S	U
 S
U S3$ s  snf s  snf ! , (       d  f       N6= f)NFTz
Requests: z	 active, z queuedzConnections: z idleÚ<z [z | z]>)Ú	__class__r8   rS   rR   r1   rQ   r—   Úcount)r   Ú
class_namer   Úrequest_is_queuedr   Úconnection_is_idleÚnum_active_requestsÚnum_queued_requestsÚnum_active_connectionsÚnum_idle_connectionsÚrequests_infoÚconnection_infos               r   Ú__repr__ÚConnectionPool.__repr__n  s  € Ø—^‘^×,Ñ,ˆ
Ø×'Ó'ØDHÇNÂNÓ SÂN¸×!2Ñ!2Ö!4ÁNÐÐ Sà7;×7HÒ7Hó"Ú7H¨×"Ñ"Ö$Ñ7Hð ð "ð #4×"9Ñ"9¸%Ó"@ÐØ"3×"9Ñ"9¸$Ó"?ÐØ%7×%=Ñ%=¸eÓ%DÐ"Ø#5×#;Ñ#;¸DÓ#AÐ ÷ (ð Ð,Ð-¨YÐ7JÐ6KÈ7ÐSð 	ð Ð2Ð3°9Ð=QÐ<RÐRWÐXð 	ð �:�,˜b  ¨s°?Ð2CÀ2ÐFÐFùò# !Tùò"÷ (Õ'ús)   £C*²C ÁC*ÁC%Á4AC*Ã 
C*Ã*
C8)rQ   rJ   rK   rI   rM   rF   rG   rO   rS   rC   rR   rL   rP   rB   rN   )NNé
   NNTFr   NNNN)rT   zssl.SSLContext | NonerU   zProxy | NonerV   ú
int | NonerW   r¾   rX   r6   rY   r7   rZ   r7   r[   Úintr\   ú
str | Noner]   rÀ   r^   zNetworkBackend | Noner_   z%typing.Iterable[SOCKET_OPTION] | Noner3   r4   )rj   r
   r3   r   )r3   úlist[ConnectionInterface])r   r   r3   r   )r�   rÁ   r3   r4   r5   )r3   r?   )NNN)r©   ztype[BaseException] | Nonerª   zBaseException | Noner«   ztypes.TracebackType | Noner3   r4   )r3   Ústr)r8   r9   r:   r;   Ú__doc__r   rq   Úpropertyru   rˆ   r†   r‡   r¡   r¦   r¬   r»   r<   r=   r!   r   r?   r?   +   s4  † ñð .2Ø"Ø&(Ø04Ø)-ØØØØ$(ØØ15Ø@DðN2à*ðN2ð ðN2ð $ð	N2ð
 $.ðN2ð 'ðN2ð ðN2ð ðN2ð ðN2ð "ðN2ð ðN2ð /ðN2ð >ðN2ð 
õN2ô`3
ðj ó'ó ð'ô"E
ôNE#ôN#ô5ôð
 04Ø*.Ø04ð	à,ðð (ðð .ð	ð
 
õ÷Gr!   r?   c                  óB   • \ rS rSr        SS jrSS jrS	S jrSrg)
rŽ   i…  c                ó6   • Xl         X l        X0l        SU l        g )NF)Ú_streamÚ_pool_requestÚ_poolÚ_closed)r   r~   r   r}   s       r   r   ÚPoolByteStream.__init__†  s   € ð ŒØ)ÔØŒ
Øˆ�r!   c              #  ó†   #   •  U R                    H  nUv •  M	     g ! [         a  nU R                  5         US eS nAff = f7fr   )rÇ   r‰   r¡   )r   Úpartr’   s      r   Ú__iter__ÚPoolByteStream.__iter__‘  s=   é € ð	 ØŸœ�Ø”
ò %øäó 	 Ø�J‰JŒLØ˜4Ðûð	 üs   ‚A„ ›Aœ
>¦9¹>¾Ac                ó  • U R                   (       dÓ  SU l         [        5          [        U R                  S5      (       a  U R                  R	                  5         S S S 5        U R
                  R                     U R
                  R                  R                  U R                  5        U R
                  R                  5       nS S S 5        U R
                  R                  W5        g g ! , (       d  f       N“= f! , (       d  f       N<= f)NTr¡   )rÊ   r   ÚhasattrrÇ   r¡   rÉ   rS   rR   rŠ   rÈ   r†   r‡   )r   r�   s     r   r¡   ÚPoolByteStream.close™  s©   € Ø�|�|ØˆDŒLÜ#Õ%Ü˜4Ÿ<™<¨×1Ñ1Ø—L‘L×&Ñ&Ô(÷ &ð —‘×1Ó1Ø—
‘
×$Ñ$×+Ñ+¨D×,>Ñ,>Ô?ØŸ*™*×DÑDÓF�÷ 2ð �J‰J×)Ñ)¨'Õ2ð ç%Õ%ú÷ 2Õ1ús   £6C&Á7A
C7Ã&
C4Ã7
D)rÊ   rÉ   rÈ   rÇ   N)r~   ztyping.Iterable[bytes]r   r   r}   r?   r3   r4   )r3   ztyping.Iterator[bytes]r5   )r8   r9   r:   r;   r   rÎ   r¡   r<   r=   r!   r   rŽ   rŽ   …  s7   † ð	à&ð	ð "ð	ð ð		ð
 
ô	ô ÷3r!   rŽ   )Ú
__future__r   ÚsslrD   ÚtypesrŒ   Ú_backends.syncr   Ú_backends.baser   r   Ú_exceptionsr   r	   Ú_modelsr
   r   r   r   Ú_synchronizationr   r   r   r   r   Ú
interfacesr   r   r   r?   rŽ   r=   r!   r   Ú<module>rÜ      sU   ðÝ "ã 
Û 
Û Û å (ß :ß Eß 6Ó 6ß DÑ DÝ &ß =÷'ñ 'ô4WGÐ%ô WG÷t
3ò 3r!   