o
    㥵i	                     @  s  U d dl mZ d dlZd dlmZ d dlmZ d dlmZ d dl	m
Z
mZ d dlmZ d dlmZ d d	lmZ d d
lmZ d dlmZ ddlmZ ejrRddlmZ ddlmZmZ G dd deeje ej!f ZG dd deeZ"edZ#de$d< ee#Z%edZ&de$d< ee&Z'dS )    )annotationsN)	ExitStack)
ContextVar)
HTTPStatus)URLContentType)HTTPException)cached_property)HTTPConnection)Request)	Annotated   )BackgroundTasks)Kui   )Statebind_contextvarc                   @  sb   e Zd ZdddZdd	d
ZedddZed ddZd!ddZe	d"ddZ
e	d#ddZdS )$r
   namestrvalue
typing.AnyreturnNonec                 C  s   || j |< d S N_environ)selfr   r    r   E/home/ubuntu/.local/lib/python3.10/site-packages/kui/wsgi/requests.py__setitem__   s   zHTTPConnection.__setitem__c                 C  s   | j |= d S r   r   )r   r   r   r   r   __delitem__   s   zHTTPConnection.__delitem__r   c                 C  s   t | di S )Nstate)r   
setdefaultr   r   r   r   r!         zHTTPConnection.stater   c                 C  s   | d S )Nappr   r#   r   r   r   r%   "   s   zHTTPConnection.apppath_paramstyping.Mapping[str, typing.Any]r   c                 C  s   | j j| jj||dS )N)path)urlreplacer%   routerurl_for)r   r   r&   r   r   r   r,   &   s   zHTTPConnection.url_forr   c                 C     | j dt S )Nbackground_tasks)r!   r"   r   r#   r   r   r   r.   )   r$   zHTTPConnection.background_tasksr   c                 C  r-   )N
exit_stack)r!   r"   r   r#   r   r   r   r/   -   r$   zHTTPConnection.exit_stackN)r   r   r   r   r   r   )r   r   r   r   )r   r   )r   r   )r   r   r&   r'   r   r   )r   r   )r   r   )__name__
__module____qualname__r   r    r	   r!   r%   r,   propertyr.   r/   r   r   r   r   r
      s    


r
   c                   @  s   e Zd ZdddZdS )HttpRequestr   Annotated[typing.Any, ContentType('application/json'), ContentType('application/x-www-form-urlencoded'), ContentType('multipart/form-data')]c                 C  s,   | j }|dkr
| jS |dv r| jS ttj)Nzapplication/json)zmultipart/form-dataz!application/x-www-form-urlencoded)content_typejsonformr   r   UNSUPPORTED_MEDIA_TYPE)r   r6   r   r   r   data3   s   
zHttpRequest.dataN)r   r5   )r0   r1   r2   r:   r   r   r   r   r4   2   s    r4   http_connectionzContextVar[HTTPConnection]http_connection_varrequestzContextVar[HttpRequest]request_var)(
__future__r   typing
contextlibr   contextvarsr   httpr   baize.datastructuresr   r   baize.exceptionsr   baize.utilsr	   
baize.wsgir
   BaiZeHTTPConnectionr   BaiZeRequesttyping_extensionsr   
backgroundr   TYPE_CHECKINGapplicationsr   utilsr   r   MutableMappingr   Anyr4   r<   __annotations__r;   r>   r=   r   r   r   r   <module>   s*    