
    ^fx%                    r   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!dS )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                f    d                     d |                     d          D                       S )N-c              3  >   K   | ]}|                                 V  d S N)
capitalize).0ps     N/var/www/html/env/lib/python3.11/site-packages/kombu/asynchronous/http/base.py	<genexpr>z#normalize_header.<locals>.<genexpr>   s*      ;;qALLNN;;;;;;    )joinsplit)keys    r   normalize_headerr!      s-    88;;CIIcNN;;;;;;r   c                      e Zd ZdZdZdZdS )r   z%Represents a mapping of HTTP headers.FN)__name__
__module____qualname____doc__complete	_prev_key r   r   r   r      s"        // H IIIr   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dS )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__GETc	                   || _         |p| j        | _        t          |          pt                      | _        t          |          | _        t          |          | _        t          |          | _        t          |          | _        |	r+|		                                D ]\  }
}t          | |
|           t          |t                    st          |pi           }|| _        d S 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//<799'
33&y11'
33&y11 	$ $ $1a####'7++ 	-gm,,Gr   c                <    | j                             ||           d S r   )r.   then)r;   callbackerrbacks      r   rA   zRequest.then   s     8W-----r   c                ,    d                     |           S )Nz&<Request: {0.method} {0.url} {0.body}>)formatr;   s    r   __repr__zRequest.__repr__   s    7>>tDDDr   )r6   NNNNNNr   )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?   rA   rG   r)   r   r   r   r   *   s        5 5t /33D 3: 3) 33%3(1333"033A3 	3 OOMHM 00	 EI<@   ". . . .E E E E Er   r   c                  n    e Zd ZdZesdZ	 	 d	dZd Zed             Z	ed             Z
ed             ZdS )
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                Z   || _         || _        ||nt                      | _        || _        |p|j        | _        d | _        |pt          j	        | j        d          | _
        || _        | j        8| j        dk     s| j        dk    r$t          | j        | j
        |           | _        d S d S d S )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    	")"5ww799*9gk
C	di C C
:49s??di#oo"49dk4@@DJJJ oor   c                "    | j         r| j         dS )zRaise if the request resulted in an HTTP error code.

        Raises
        ------
            :class:`~kombu.exceptions.HttpError`
        N)rb   rF   s    r   raise_for_errorzResponse.raise_for_error   s      : 	*	 	r   c                h    | j         %| j        | j                                        | _         | j         S )zThe full contents of the response body.

        Note:
        ----
            Accessing this property will evaluate the buffer
            and subsequent accesses will be cached.
        )rd   r`   getvaluerF   s    r   rH   zResponse.body   s1     :{&![1133
zr   c                    | j         S r   )r_   rF   s    r   status_codezResponse.status_code   
    yr   c                    | j         S r   )rH   rF   s    r   contentzResponse.content   ro   r   )NNNNN)r#   r$   r%   r&   r[   r\   r?   rj   propertyrH   rn   rq   r)   r   r   r   r      s         6  @@	 <@8<A A A A     X   X   X  r   r   c              #    K   	 d V \  }}|                     d          r|sd|_        (|d                                         rI|j        }d                    |                    |          pd|                                g          ||<   nB|                    dd          \  }} | |          x}|_        |                                ||<   )N   zHTTP/Tr     :)	
startswithr'   isspacer(   r   rh   lstripr   strip)keytliner3   pkeyr    values         r   header_parserr      s      )%%w??7## 	) 		)#G!W__ 	)$DHHgkk$&7&7&=2t{{}}%MNNGDMMC++JC&*d3ii/C'# ;;==GCL)r   c                  F    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dS )
BaseClientc                :    || _         t                      | _        d S r   )hubr   _header_parser)r;   r   r<   s      r   r?   zBaseClient.__init__   s    +oor   c                    t          |          pg D ]:}t          || j                  s | j        |fi |}|                     |           ;d S r   )r   r:   r   add_request)r;   r^   r<   reqs       r   performzBaseClient.perform   sl    g&&," 	" 	"Cc4<00 2"dl311&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                    d S r   r)   rF   s    r   closezBaseClient.close   s    r   c                    	 | j                             t          |          |f           d S # t          $ r t	                      | _         Y d S w xY wr   )r   sendr   StopIterationr   )r;   r3   r}   s      r   r2   zBaseClient.on_header  sa    	2$$l4&8&8'%BCCCCC 	2 	2 	2"///D	2s   )- AAc                    | S r   r)   rF   s    r   	__enter__zBaseClient.__enter__	  s    r   exc_typetype[BaseException] | Noneexc_valBaseException | Noneexc_tbTracebackType | NonereturnNonec                .    |                                   d S r   )r   )r;   r   r   r   s       r   __exit__zBaseClient.__exit__  s     	

r   N)r   r   r   r   r   r   r   r   )r#   r$   r%   r   r   r   r?   r   r   r   r2   r   r   r)   r   r   r   r      s        GGH. . ." " "@ @ @  2 2 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 1 1 1 1 1 1 1 1 & & & & & & # # # # # # - - - - - - 6 6 6 6 6 6 6 6 $######
,ws'(( 	< < <
 
 
 
 
d 
 
 
 
^E ^E ^E ^E ^E ^E ^E ^EBM M M M M M M M` ' ) ) ) )"$ $ $ $ $ $ $ $ $ $r   