
    zi                        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dl	m
Z
 ej        rd dlmZ d dlmZ  ej        d	          Zd
ej        e         dej        e         fdZ G d de          Z G d de
          ZdS )    N   )RequestResponse)SyncByteStream   )BaseTransport)
OptExcInfo)WSGIApplication_Tbodyreturnc                 b    t          |           } | D ]}|rt          j        |g|           c S g S N)iter	itertoolschain)r   chunks     a/var/www/tmov.alphamb/tmov_inventario/venv/lib/python3.11/site-packages/httpx/_transports/wsgi.py_skip_leading_empty_chunksr      sH    ::D 2 2 	2?E7D11111	2I    c                   ^    e Zd Zdej        e         ddfdZdej        e         fdZddZ	dS )WSGIByteStreamresultr   Nc                 Z    t          |dd           | _        t          |          | _        d S )Nclose)getattr_closer   _result)selfr   s     r   __init__zWSGIByteStream.__init__   s(    fgt441&99r   c              #   &   K   | j         D ]}|V  d S r   )r   )r   parts     r   __iter__zWSGIByteStream.__iter__   s,      L 	 	DJJJJ	 	r   c                 @    | j         |                                   d S d S r   )r   )r   s    r   r   zWSGIByteStream.close"   s#    ;"KKMMMMM #"r   )r   N)
__name__
__module____qualname__typingIterablebytesr    Iteratorr#   r    r   r   r   r      ss        :vu5 :$ : : : :&/%0         r   r   c                   l    e Zd ZdZ	 	 	 	 dddded	ed
edej        ej                 ddfdZ	de
def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 transport instance explicitly.
    This allows you to include any additional configuration arguments specific
    to the WSGITransport class:

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

    Arguments:

    * `app` - The WSGI 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 WSGI application should be mounted.
    * `remote_addr` - A string indicating the client IP of incoming requests.
    ```
    T 	127.0.0.1Nappr
   raise_app_exceptionsscript_nameremote_addrwsgi_errorsr   c                 L    || _         || _        || _        || _        || _        d S r   )r1   r2   r3   r4   r5   )r   r1   r2   r3   r4   r5   s         r   r    zWSGITransport.__init__H   s1     $8!&&&r   requestc                    |                                  t          j        |j                  }|j        j        pddd|j        j                 }d|j        j        || j        pt          j	        ddd|j
        | j        |j        j        |j        j                            d          |j        j        t!          |          d| j        d	}|j        j        D ]a\  }}|                    d                                                              d
d          }|dvrd|z   }|                    d          ||<   bd d d 	 ddt           dt,          j        t,          j        t           t           f                  dt,          j        d         dt,          j        t6          gt,          j        f         ffd}|                     ||          }	t=          |	          }
J J rd         r| j        rd         tA          !                                d                   }d D             }tE          |||
          S )NP   i  )httphttps)r   r   TFasciizHTTP/1.1)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SERVER_PROTOCOLREMOTE_ADDR-_)CONTENT_TYPECONTENT_LENGTHHTTP_statusresponse_headersexc_infor	   r   c                     | ||d S )Nc                     d S r   r,   )rF   s    r   <lambda>zFWSGITransport.handle_request.<locals>.start_response.<locals>.<lambda>   s    T r   r,   )rJ   rK   rL   seen_exc_infoseen_response_headersseen_statuss      r   start_responsez4WSGITransport.handle_request.<locals>.start_responsev   s     !K$4!$M!>!r   r   r   c                 h    g | ]/\  }}|                     d           |                     d           f0S )r<   )encode).0keyvalues      r   
<listcomp>z0WSGITransport.handle_request.<locals>.<listcomp>   sI     
 
 
U ZZ  %,,w"7"78
 
 
r   )headersstreamr   )#readioBytesIOcontenturlportschemer5   sysstderrmethodr3   pathquerydecodehoststrr4   rZ   rawupperreplacer(   ListTupleOptionalCallabler*   Anyr1   r   r2   intsplitr   )r   r7   
wsgi_inputra   environ
header_keyheader_valuerW   rS   r   r[   status_coderZ   rP   rQ   rR   s                @@@r   handle_requestzWSGITransport.handle_requestV   st   Z00
{QB#=#=gk>P#Q"&{1$+9sz $!&"%n+ )#K-44W==";+t99)+
 
" )0(; 	8 	8$J##G,,2244<<S#FFC<<<m'..w77GCLL $
 7;		" 		"		"$k&,sCx*@A		" ol3		" _eWfj01			" 		" 		" 		" 		" 		" 		" 		" '>22''&&&$000 	#]1- 	#$2K 	#""+++--a011
 
3
 
 

 WVDDDDr   )Tr/   r0   N)r%   r&   r'   __doc__boolrj   r(   rp   TextIOr    r   r   rz   r,   r   r   r.   r.   '   s         F &*&6:' '' #' 	'
 ' _V]3' 
' ' ' ':Eg :E( :E :E :E :E :E :Er   r.   )r]   r   rc   r(   _modelsr   r   _typesr   baser   TYPE_CHECKING	_typeshedr	   _typeshed.wsgir
   TypeVarr   r)   r   r   r.   r,   r   r   <module>r      sJ   				     



  ' ' ' ' ' ' ' ' # # # # # #      	 /$$$$$$......V^DV_R%8 V_R=P        ^   iE iE iE iE iEM iE iE iE iE iEr   