
    h                        S SK Jr  S SKrS SKrS SKrS SKrSSKJrJr  SSK	J
r
  SSKJr  \R                  (       a  S SKJr  S S	KJr  \R$                  " S
5      rS/rSS jr " S S\
5      r " S S\5      rg)    )annotationsN   )RequestResponse)SyncByteStream   )BaseTransport)
OptExcInfo)WSGIApplication_TWSGITransportc                p    [        U 5      n U  H$  nU(       d  M  [        R                  " U/U 5      s  $    / $ N)iter	itertoolschain)bodychunks     H/var/www/html/env/lib/python3.13/site-packages/httpx/_transports/wsgi.py_skip_leading_empty_chunksr      s4    :D5??E7D11  I    c                  2    \ rS rSrSS jrSS jrS	S jrSrg)
WSGIByteStream   c                H    [        USS 5      U l        [        U5      U l        g )Nclose)getattr_closer   _result)selfresults     r   __init__WSGIByteStream.__init__   s    fgt41&9r   c              #  :   #    U R                    H  nUv   M	     g 7fr   )r   )r    parts     r   __iter__WSGIByteStream.__iter__#   s     LLDJ !s   c                @    U R                   b  U R                  5         g g r   )r   )r    s    r   r   WSGIByteStream.close'   s    ;;"KKM #r   )r   r   N)r!   ztyping.Iterable[bytes]returnNone)r*   ztyping.Iterator[bytes])r*   r+   )__name__
__module____qualname____firstlineno__r"   r&   r   __static_attributes__ r   r   r   r      s    :r   r   c                  N    \ rS rSrSr    S           SS jjrS	S jrSrg)
r   ,   a  
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.
```
Nc                @    Xl         X l        X0l        X@l        XPl        g r   )appraise_app_exceptionsscript_nameremote_addrwsgi_errors)r    r5   r6   r7   r8   r9   s         r   r"   WSGITransport.__init__M   s!     $8!&&&r   c                  ^^^ UR                  5         [        R                  " UR                  5      nUR                  R
                  =(       d    SSS.UR                  R                     nSUR                  R                  UU R                  =(       d    [        R                  SSSUR                  U R                  UR                  R                  UR                  R                  R                  S5      UR                  R                  [!        U5      SU R"                  S	.nUR$                  R&                   HR  u  pVUR                  S5      R)                  5       R+                  S
S5      nUS;  a  SU-   nUR                  S5      XG'   MT     S mS mS m S       SUUU4S jjjnU R-                  XH5      n	[/        U	5      n
Tc   eTc   eT(       a   TS   (       a  U R0                  (       a  TS   e[3        TR5                  5       S   5      nT VVs/ s H'  u  p|UR7                  S5      UR7                  S5      4PM)     nnn[9        XU
S9$ s  snnf )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_c                   > U mUmUmS $ )Nc                    g r   r1   )rI   s    r   <lambda>FWSGITransport.handle_request.<locals>.start_response.<locals>.<lambda>   s    Tr   r1   )statusresponse_headersexc_infoseen_exc_infoseen_response_headersseen_statuss      r   start_response4WSGITransport.handle_request.<locals>.start_response{   s     !K$4!$M!!r   r   r   )headersstreamr   )rQ   strrR   zlist[tuple[str, str]]rS   zOptExcInfo | Noner*   z$typing.Callable[[bytes], typing.Any])readioBytesIOcontenturlportschemer9   sysstderrmethodr7   pathquerydecodehostr[   r8   rY   rawupperreplacer5   r   r6   intsplitencoder   )r    request
wsgi_inputra   environ
header_keyheader_valuekeyrW   r!   rZ   status_codevaluerY   rT   rU   rV   s                 @@@r   handle_requestWSGITransport.handle_request[   s.   ZZ0
{{QB#=gkk>P>P#Q"&{{11$++9szz $!&"%nn++ ))#KK--44W=";;++t9)++
" )0(;(;$J##G,224<<S#FC<<m'..w7GL	 )<  $
 +/		"		"3		" (		" 2			" 		" '2'&&&$000]1-$2K2K""+++-a01 4
3
 ZZ %,,w"783 	 

 VDD
s   .I)r5   r6   r8   r7   r9   )T z	127.0.0.1N)r5   r   r6   boolr7   r[   r8   r[   r9   ztyping.TextIO | Noner*   r+   )rp   r   r*   r   )r,   r-   r.   r/   __doc__r"   rx   r0   r1   r   r   r   r   ,   s[    F &*&,0'' #' 	'
 ' *' 
':Er   )r   typing.Iterable[_T]r*   r}   )
__future__r   r]   r   rc   typing_modelsr   r   _typesr   baser	   TYPE_CHECKING	_typeshedr
   _typeshed.wsgir   TypeVarr   __all__r   r   r   r1   r   r   <module>r      se    " 	  
  ' # 	$.^^D 
^ iEM iEr   