Ë
    šQjx%  ã                  óD  — d Z ddlmZ ddlZddlmZ ddlmZ ddlm	Z	m
Z
mZ ddlmZ ddlmZ dd	lmZ dd
lmZmZ erddlmZ dZ eed«      Z ed¬«      d„ «       Z G d„ de«      Ze	j:                   G d„ d«      «       Z G d„ d«      Zeefd„«       Z  G d„ d«      Z!y)z&Base async HTTP client implementation.é    )ÚannotationsN)Ú	responses)ÚTYPE_CHECKING)ÚThenableÚmaybe_promiseÚpromise)Ú	HttpError)Úcoro)Úbytes_to_str)Ú
maybe_listÚmemoize)ÚTracebackType)ÚHeadersÚResponseÚRequestÚpypy_version_infoiè  )Úmaxsizec                óP   — dj                  d„ | j                  d«      D «       «      S )Nú-c              3  ó<   K  — | ]  }|j                  «       –— Œ y ­w©N)Ú
capitalize)Ú.0Úps     úX/var/www/html/truck-me/venv/lib/python3.12/site-packages/kombu/asynchronous/http/base.pyú	<genexpr>z#normalize_header.<locals>.<genexpr>   s   è ø€ Ò; q�A—L‘L—NÑ;ùs   ‚)ÚjoinÚsplit)Úkeys    r   Únormalize_headerr       s   € à�8‰8Ñ;¨C¯I©I°c«NÔ;Ó;Ð;ó    c                  ó   — e Zd ZdZdZdZy)r   z%Represents a mapping of HTTP headers.FN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__ÚcompleteÚ	_prev_key© r!   r   r   r      s   „ Ù/ð €Hð �Ir!   r   c                  ó€   — e Zd ZdZdxZxZxZxZxZxZ	xZ
xZxZxZxZxZZdZdZdZdZdZdZesdZ	 	 	 d
d„Zdd„Zd	„ Zy)r   a?  A HTTP Request.

    Arguments:
    ---------
        url (str): The URL to request.
        method (str): The HTTP method to use (defaults to ``GET``).

    Keyword Arguments:
    -----------------
        headers (Dict, ~kombu.asynchronous.http.Headers): Optional headers for
            this request
        body (str): Optional body for this request.
        connect_timeout (float): Connection timeout in float seconds
            Default is 30.0.
        timeout (float): Time in float seconds before the request times out
            Default is 30.0.
        follow_redirects (bool): Specify if the client should follow redirects
            Enabled by default.
        max_redirects (int): Maximum number of redirects (default 6).
        use_gzip (bool): Allow the server to use gzip compression.
            Enabled by default.
        validate_cert (bool): Set to true if the server certificate should be
            verified when performing ``https://`` requests.
            Enabled by default.
        auth_username (str): Username for HTTP authentication.
        auth_password (str): Password for HTTP authentication.
        auth_mode (str): Type of HTTP authentication (``basic`` or ``digest``).
        user_agent (str): Custom user agent for this request.
        network_interface (str): Network interface to use for this request.
        on_ready (Callable): Callback to be called when the response has been
            received. Must accept single ``response`` argument.
        on_stream (Callable): Optional callback to be called every time body
            content has been read from the socket.  If specified then the
            response body and buffer attributes will not be available.
        on_timeout (callable): Optional callback to be called if the request
            times out.
        on_header (Callable): Optional callback to be called for every header
            line received from the server.  The signature
            is ``(headers, line)`` and note that if you want
            ``response.headers`` to be populated then your callback needs to
            also call ``client.on_header(headers, line)``.
        on_prepare (Callable): Optional callback that is implementation
            specific (e.g. curl client will pass the ``curl`` instance to
            this callback).
        proxy_host (str): Optional proxy host.  Note that a ``proxy_port`` must
            also be provided or a :exc:`ValueError` will be raised.
        proxy_username (str): Optional username to use when logging in
            to the proxy.
        proxy_password (str): Optional password to use when authenticating
            with the proxy server.
        ca_certs (str): Custom CA certificates file to use.
        client_key (str): Optional filename for client SSL key.
        client_cert (str): Optional filename for client SSL certificate.
    Ng      >@Té   )
ÚurlÚmethodÚon_readyÚ
on_timeoutÚ	on_streamÚ
on_prepareÚ	on_headerÚheadersÚ__weakref__Ú__dict__c	                óŽ  — || _         |xs | j                  | _        t        |«      xs
 t        «       | _        t        |«      | _        t        |«      | _        t        |«      | _        t        |«      | _        |	r%|	j                  «       D ]  \  }
}t        | |
|«       Œ t        |t        «      st        |xs i «      }|| _        y r   )r,   r-   r   r   r.   r/   r0   r1   r2   ÚitemsÚsetattrÚ
isinstancer   r3   )Úselfr,   r-   r.   r/   r0   r1   r2   r3   ÚkwargsÚkÚvs               r   Ú__init__zRequest.__init__t   s¥   € ð ˆŒØÒ+ §¡ˆŒÜ% hÓ/Ò<´7³9ˆŒÜ'¨
Ó3ˆŒÜ& yÓ1ˆŒÜ'¨
Ó3ˆŒÜ& yÓ1ˆŒÙØŸ™›ò $‘��1Ü˜˜a Õ#ð$ä˜'¤7Ô+Ü˜gšm¨Ó,ˆGØˆ�r!   c                ó<   — | j                   j                  ||«       y r   )r.   Úthen)r:   ÚcallbackÚerrbacks      r   r@   zRequest.then…   s   € Ø�‰×Ñ˜8 WÕ-r!   c                ó$   — dj                  | «      S )Nz&<Request: {0.method} {0.url} {0.body}>)Úformat©r:   s    r   Ú__repr__zRequest.__repr__ˆ   s   € Ø7×>Ñ>¸tÓDÐDr!   )ÚGETNNNNNNr   )r#   r$   r%   r&   ÚbodyÚ
user_agentÚnetwork_interfaceÚauth_usernameÚauth_passwordÚ	auth_modeÚ
proxy_hostÚ
proxy_portÚproxy_usernameÚproxy_passwordÚca_certsÚ
client_keyÚclient_certÚconnect_timeoutÚrequest_timeoutÚfollow_redirectsÚmax_redirectsÚuse_gzipÚvalidate_certÚPYPYÚ	__slots__r>   r@   rF   r)   r!   r   r   r   *   s·   „ ñ5ðt /3ð3€Dð 3ˆ:ð 3Ð)ð 3Øð3Ø%ð3Ø(1ð3àð3àð3à"0ð3à3Að3ð 	ð3ð  à€OØ€OØÐØ€MØ€HØ€Máð0ˆ	ð EIØ<@Øóó".óEr!   r   c                  óZ   — e Zd ZdZesdZ	 	 d	d„Zd„ Zed„ «       Z	ed„ «       Z
ed„ «       Zy)
r   a	  HTTP Response.

    Arguments
    ---------
        request (~kombu.asynchronous.http.Request): See :attr:`request`.
        code (int): See :attr:`code`.
        headers (~kombu.asynchronous.http.Headers): See :attr:`headers`.
        buffer (bytes): See :attr:`buffer`
        effective_url (str): See :attr:`effective_url`.
        status (str): See :attr:`status`.

    Attributes
    ----------
        request (~kombu.asynchronous.http.Request): object used to
            get this response.
        code (int): HTTP response code (e.g. 200, 404, or 500).
        headers (~kombu.asynchronous.http.Headers): HTTP headers
            for this response.
        buffer (bytes): Socket read buffer.
        effective_url (str): The destination url for this request after
            following redirects.
        error (Exception): Error instance if the request resulted in
            a HTTP error code.
        status (str): Human equivalent of :attr:`code`,
            e.g. ``OK``, `Not found`, or 'Internal Server Error'.
    )	ÚrequestÚcoder3   ÚbufferÚeffective_urlÚerrorÚstatusÚ_bodyr4   Nc                ó�  — || _         || _        |�|n	t        «       | _        || _        |xs |j
                  | _        d | _        |xs  t        j                  | j                  d«      | _
        || _        | j                  €F| j                  dk  s| j                  dkD  r't        | j                  | j                  | «      | _        y y y )NÚUnknownéÈ   i+  )r^   r_   r   r3   r`   r,   ra   rd   r   Úgetrc   rb   r	   )r:   r^   r_   r3   r`   ra   rb   rc   s           r   r>   zResponse.__init__¬   s    € àˆŒØˆŒ	Ø")Ð"5‘w¼7»9ˆŒØˆŒØ*Ò9¨g¯k©kˆÔØˆŒ
àÒC¤	§¡¨d¯i©i¸Ó CˆŒØˆŒ
Ø�:‰:Ð 4§9¡9¨s¢?°d·i±iÀ#²oÜ" 4§9¡9¨d¯k©k¸4Ó@ˆD�Jð 7FÐr!   c                ó4   — | j                   r| j                   ‚y)z�Raise if the request resulted in an HTTP error code.

        Raises
        ------
            :class:`~kombu.exceptions.HttpError`
        N)rb   rE   s    r   Úraise_for_errorzResponse.raise_for_errorº   s   € ð �:Š:Ø—*‘*Ðð r!   c                óˆ   — | j                   €+| j                  �| j                  j                  «       | _         | j                   S )z½The full contents of the response body.

        Note:
        ----
            Accessing this property will evaluate the buffer
            and subsequent accesses will be cached.
        )rd   r`   ÚgetvaluerE   s    r   rH   zResponse.bodyÄ   s6   € ð �:‰:ÐØ�{‰{Ð&Ø!Ÿ[™[×1Ñ1Ó3�”
Ø�z‰zÐr!   c                ó   — | j                   S r   )r_   rE   s    r   Ústatus_codezResponse.status_codeÓ   ó   € à�y‰yÐr!   c                ó   — | j                   S r   )rH   rE   s    r   ÚcontentzResponse.content×   ro   r!   )NNNNN)r#   r$   r%   r&   r[   r\   r>   rj   ÚpropertyrH   rn   rq   r)   r!   r   r   r   Œ   sd   „ ññ6 ð@ˆ	ð <@Ø8<óAòð ñó ðð ñó ðð ñó ñr!   r   c              #  óp  K  — 	 d –—\  }}|j                  d«      rŒ|sd|_        Œ$|d   j                  «       rD|j                  }dj	                  |j                  |«      xs d|j                  «       g«      ||<   n7|j                  dd«      \  }} | |«      x}|_        |j                  «       ||<   Œ²­w)Né   zHTTP/Tr   ú Ú ú:)	Ú
startswithr'   Úisspacer(   r   rh   Úlstripr   Ústrip)ÚkeytÚliner3   Úpkeyr   Úvalues         r   Úheader_parserr€   Ü   s¬   è ø€ à
Ú‰ˆˆwØ�?‰?˜7Ô#ØÙØ#ˆGÔØØ�!‰W�_‰_ÔØ×$Ñ$ˆDØŸH™H g§k¡k°$Ó&7Ò&=¸2¸t¿{¹{»}Ð%MÓNˆG�DŠMàŸ™ C¨Ó+‰JˆC�Ù&*¨3£iÐ/ˆC�'Ô#Ø Ÿ;™;›=ˆG�C‰Lð ùs   ‚B4B6c                  óT   — e Zd ZeZeZeZd„ Zd„ Zd„ Zd„ Z	d„ Z
d„ Z	 	 	 	 	 	 	 	 d	d„Zy)
Ú
BaseClientc                ó0   — || _         t        «       | _        y r   )Úhubr€   Ú_header_parser)r:   r„   r;   s      r   r>   zBaseClient.__init__ó   s   € ØˆŒÜ+›oˆÕr!   c                ó    — t        |«      xs g D ]<  }t        || j                  «      s | j                  |fi |¤Ž}| j                  |«       Œ> y r   )r   r9   r   Úadd_request)r:   r^   r;   Úreqs       r   ÚperformzBaseClient.perform÷   sL   € Ü˜gÓ&Ò,¨"ò 	"ˆCÜ˜c 4§<¡<Ô0Ø"�d—l‘l 3Ñ1¨&Ñ1�Ø×Ñ˜SÕ!ñ	"r!   c                ó   — t        d«      ‚)Nzmust implement add_request)ÚNotImplementedError)r:   r^   s     r   r‡   zBaseClient.add_requestý   s   € Ü!Ð">Ó?Ð?r!   c                 ó   — y r   r)   rE   s    r   ÚclosezBaseClient.close   s   € Ør!   c                óŽ   — 	 | j                   j                  t        |«      |f«       y # t        $ r t	        «       | _         Y y w xY wr   )r…   Úsendr   ÚStopIterationr€   )r:   r3   r}   s      r   r2   zBaseClient.on_header  s>   € ð	2Ø×Ñ×$Ñ$¤l°4Ó&8¸'Ð%BÕCøÜò 	2Ü"/£/ˆDÖð	2ús   ‚&) ©AÁAc                ó   — | S r   r)   rE   s    r   Ú	__enter__zBaseClient.__enter__	  s   € Øˆr!   c                ó$   — | j                  «        y r   )r�   )r:   Úexc_typeÚexc_valÚexc_tbs       r   Ú__exit__zBaseClient.__exit__  s   € ð 	�
‰
�r!   N)r”   ztype[BaseException] | Noner•   zBaseException | Noner–   zTracebackType | NoneÚreturnÚNone)r#   r$   r%   r   r   r   r>   r‰   r‡   r�   r2   r’   r—   r)   r!   r   r‚   r‚   î   s[   „ Ø€GØ€GØ€Hò.ò"ò@òò2òðà,ðð &ðð %ð	ð
 
ôr!   r‚   )"r&   Ú
__future__r   ÚsysÚhttp.clientr   Útypingr   Úviner   r   r   Úkombu.exceptionsr	   Úkombu.utils.compatr
   Úkombu.utils.encodingr   Úkombu.utils.functionalr   r   Útypesr   Ú__all__Úhasattrr[   r    Údictr   Úregisterr   r   r€   r‚   r)   r!   r   ú<module>r¨      s·   ðÙ ,å "ã 
Ý !Ý  ç 1Ñ 1å &Ý #Ý -ß 6áÝ#à
,€áˆsÐ'Ó(€ñ 	�Ôñ<ó ð<ô
ˆdô 
ð 
×Ñ÷^Eð ^Eó ð^E÷BMñ Mð` Ø'ò )ó ð)÷"$ò $r!   