o
    Eh                     @   sx   d dl Z d dlZd dlZd dlZddlmZmZ ddlmZ dej	dej	fddZ
G d	d
 d
ejZG dd deZdS )    N   )
ByteStreamIteratorStream)warn_deprecatedbodyreturnc                 C   s,   t | } | D ]}|rt|g|   S qg S N)iter	itertoolschain)r   chunk r   Q/var/www/html/env_mimamsha/lib/python3.10/site-packages/httpx/_transports/wsgi.py_skip_leading_empty_chunks   s   r   c                   @   s   e Zd ZdZ			ddejdededed	d
f
ddZ	
	
	
dde	dej
e	e	eje e	f dejej
e	e	f  dejdejeeje f d	ej
e	ee	ejej
e	e	f  ejf fddZd
S )WSGITransporta  
    A custom transport that handles sending requests directly to an WSGI app.
    The simplest way to use this functionality is to use the `app` argument.

    ```
    client = httpx.Client(app=app)
    ```

    Alternatively, you can setup the dispatch instance explicitly.
    This allows you to include any additional configuration arguments specific
    to the WSGITransport class:

    ```
    dispatch = httpx.WSGITransport(
        app=app,
        script_name="/submount",
        remote_addr="1.2.3.4"
    )
    client = httpx.Client(dispatch=dispatch)
    ```

    Arguments:

    * `app` - The ASGI application.
    * `raise_app_exceptions` - Boolean indicating if exceptions in the application
       should be raised. Default to `True`. Can be set to `False` for use cases
       such as testing the content of a client 500 response.
    * `script_name` - The root path on which the ASGI application should be mounted.
    * `remote_addr` - A string indicating the client IP of incoming requests.
    ```
    T 	127.0.0.1appraise_app_exceptionsscript_nameremote_addrr   Nc                 C   s   || _ || _|| _|| _d S r   r   r   r   r   selfr   r   r   r   r   r   r   __init__4   s   
zWSGITransport.__init__methodurlheadersstreamtimeoutc                    s  |d u rg n|}|d u rt dn|}|\}}}}	|	d\}
}}d|dtddd |D t ddd| | j|
d|d|dt|| jd	}|D ]\}}|d	 
d
d}|dvrid| }|d||< qRd d d  	 ddtdtdtjdd f fdd}| ||}t|}d usJ d usJ  r| jr d t d }dd D }tdd |D }d|d||fS )N       ?)   r   asciic                 S   s   g | ]}|qS r   r   .0r   r   r   r   
<listcomp>V   s    z)WSGITransport.request.<locals>.<listcomp>TF)zwsgi.versionzwsgi.url_schemez
wsgi.inputzwsgi.errorszwsgi.multithreadzwsgi.multiprocesszwsgi.run_onceREQUEST_METHODSCRIPT_NAME	PATH_INFOQUERY_STRINGSERVER_NAMESERVER_PORTREMOTE_ADDR-_)CONTENT_TYPECONTENT_LENGTHHTTP_statusresponse_headersexc_infor   c                    s   | || d S r   r   )r3   r4   r5   seen_exc_infoseen_response_headersseen_statusr   r   start_responsem   s   z-WSGITransport.request.<locals>.start_responser"   r   c                 S   s$   g | ]\}}| d | d fqS )r#   )encode)r%   keyvaluer   r   r   r&      s    c                 s   s    | ]}|V  qd S r   r   r$   r   r   r   	<genexpr>   s    z(WSGITransport.request.<locals>.<genexpr>s   HTTP/1.1r   )r   	partitiondecodeioBytesIOjoinr   strr   upperreplacelisttypingAnyr   r   r   intsplitr   )r   r   r   r   r   r   schemehostport	full_pathpathr/   queryenviron
header_keyheader_valuer<   r:   resultstatus_coder   r6   r   request@   sb   
zWSGITransport.requestTr   r   )NNN)__name__
__module____qualname____doc__rH   CallableboolrD   r   bytesTupleOptionalrJ   ListhttpcoreSyncByteStreamDictfloatrW   r   r   r   r   r      sN    #
r   c                       s<   e Zd Z			ddejdedededd	f
 fd
dZ  ZS )WSGIDispatchTr   r   r   r   r   r   r   Nc                    s    t d t j||||d d S )Nz4WSGIDispatch is deprecated, please use WSGITransportr   )r   superr   r   	__class__r   r   r      s   
zWSGIDispatch.__init__rX   )	rY   rZ   r[   rH   r]   r^   rD   r   __classcell__r   r   ri   r   rg      s    rg   )rA   r
   rH   rc   _content_streamsr   r   _utilsr   Iterabler   SyncHTTPTransportr   rg   r   r   r   r   <module>   s    v