
    _f                     :    d dl mZ ddlmZ  G d de          ZdS )    )AsyncConsumer   )StopConsumerc                   P    e Zd ZdZd ZddddZddd	Zd
 Zd Zd Z	d Z
d ZdS )AsyncHttpConsumerzf
    Async HTTP consumer. Provides basic primitives for building asynchronous
    HTTP endpoints.
    c                     g | _         d S )N)body)selfargskwargss      G/var/www/html/env/lib/python3.11/site-packages/channels/generic/http.py__init__zAsyncHttpConsumer.__init__   s    			       N)statusheadersc                   K   |g }n6t          |t                    r!t          |                                          }|                     d||d           d{V  dS )a?  
        Sets the HTTP response status and headers. Headers may be provided as
        a list of tuples or as a dictionary.

        Note that the ASGI spec requires that the protocol server only starts
        sending the response to the client after ``self.send_body`` has been
        called the first time.
        Nzhttp.response.start)typer   r   )
isinstancedictlistitemssend)r
   r   r   s      r   send_headerszAsyncHttpConsumer.send_headers   s       ?GG&& 	,7==??++Gii*fQQ
 
 	
 	
 	
 	
 	
 	
 	
 	
 	
r   F)	more_bodyc                   K   t          |t                    s
J d            |                     d||d           d{V  dS )a  
        Sends a response body to the client. The method expects a bytestring.

        Set ``more_body=True`` if you want to send more body content later.
        The default behavior closes the response, and further messages on
        the channel will be ignored.
        zBody is not byteszhttp.response.body)r   r	   r   N)r   bytesr   )r
   r	   r   s      r   	send_bodyzAsyncHttpConsumer.send_body!   sr       $&&;;(;;;&ii)4iPP
 
 	
 	
 	
 	
 	
 	
 	
 	
 	
r   c                 j   K    | j         dd|i| d{V  |                     |           d{V  dS )z
        Sends a response to the client. This is a thin wrapper over
        ``self.send_headers`` and ``self.send_body``, and everything said
        above applies here as well. This method may only be called once.
        r   N )r   r   )r
   r   r	   r   s       r   send_responsezAsyncHttpConsumer.send_response.   sb        d88v8888888888nnT"""""""""""r   c                 $   K   t          d          )z
        Receives the request body as a bytestring. Response may be composed
        using the ``self.send*`` methods; the return value of this method is
        thrown away.
        z?Subclasses of AsyncHttpConsumer must provide a handle() method.)NotImplementedError)r
   r	   s     r   handlezAsyncHttpConsumer.handle7   s       "M
 
 	
r   c                 
   K   dS )zh
        Overrideable place to run disconnect handling. Do not send anything
        from here.
        Nr    )r
   s    r   
disconnectzAsyncHttpConsumer.disconnectA   s      
 	r   c                 t  K   d|v r | j                             |d                    |                    d          s|	 |                     d                    | j                              d{V  |                                  d{V  n# |                                  d{V  w xY wt                      dS )z
        Async entrypoint - concatenates body fragments and hands off control
        to ``self.handle`` when the body has been completely received.
        r	   r   r   N)r	   appendgetr$   joinr&   r   r
   messages     r   http_requestzAsyncHttpConsumer.http_requestH   s      
 WIWV_---{{;'' 	!(kk#((49"5"5666666666oo''''''''''doo''''''''''.. 	! 	!s   3B B'c                 V   K   |                                   d{V  t                      )zG
        Let the user do their cleanup and close the consumer.
        N)r&   r   r+   s     r   http_disconnectz!AsyncHttpConsumer.http_disconnectV   s4       oonnr   )__name__
__module____qualname____doc__r   r   r   r!   r$   r&   r-   r/   r    r   r   r   r      s         
   ,/ 
 
 
 
 
$ 27 
 
 
 
 
# # #
 
 
  ! ! !    r   r   N)channels.consumerr   
exceptionsr   r   r    r   r   <module>r6      sg    + + + + + + % % % % % %U U U U U U U U U Ur   