xL iddlmZddlZddlZddlZddlZddlmZmZddl m Z ddl m Z ejr ddlmZdd lmZej$d Zd gZdd ZGd de ZGdd e Zy)) annotationsN)RequestResponse)SyncByteStream) BaseTransport) OptExcInfo)WSGIApplication_T WSGITransportc`t|}|D]}|stj|g|cSgSN)iter itertoolschain)bodychunks \/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/httpx/_transports/wsgi.py_skip_leading_empty_chunksrs7 :D2 ??E7D1 12 Ic$eZdZddZddZddZy)WSGIByteStreamcHt|dd|_t||_y)Nclose)getattr_closer_result)selfresults r__init__zWSGIByteStream.__init__sfgt4 1&9 rc#6K|jD]}|ywr)r)rparts r__iter__zWSGIByteStream.__iter__#sLL DJ sc>|j|jyyr)r)rs rrzWSGIByteStream.close's ;; " KKM #rN)r ztyping.Iterable[bytes]returnNone)r&ztyping.Iterator[bytes])r&r')__name__ __module__ __qualname__r!r$rrrrrs:rrc@eZdZdZ d ddZddZy)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. ``` NcJ||_||_||_||_||_yr)appraise_app_exceptions script_name remote_addr wsgi_errors)rr.r/r0r1r2s rr!zWSGITransport.__init__Ms+$8!&&&rcz|jtj|j}|jj xsddd|jj }d|jj ||jxstjddd|j|j|jj|jjjd|jjt!|d|j"d }|j$j&D]Q\}}|jdj)j+d d }|d vrd |z}|jd||<Sddd d dfd }|j-||} t/| } JJrdr|j0rdt3j5d} D cgc]'\}} |j7d| j7df)} }} t9| | | Scc} }w)NPi)httphttps)rrTFasciizHTTP/1.1)z wsgi.versionzwsgi.url_schemez wsgi.inputz wsgi.errorszwsgi.multithreadzwsgi.multiprocessz wsgi.run_onceREQUEST_METHOD SCRIPT_NAME PATH_INFO QUERY_STRING SERVER_NAME SERVER_PORTSERVER_PROTOCOL REMOTE_ADDR-_) CONTENT_TYPECONTENT_LENGTHHTTP_c|||dS)Ncyrr+)rAs rzFWSGITransport.handle_request..start_response..srr+)statusresponse_headersexc_info seen_exc_infoseen_response_headers seen_statuss rstart_responsez4WSGITransport.handle_request..start_response{s !K$4 !$M! !rrr)headersstreamr)rHstrrIzlist[tuple[str, str]]rJzOptExcInfo | Noner&z$typing.Callable[[bytes], typing.Any])readioBytesIOcontenturlportschemer2sysstderrmethodr0pathquerydecodehostrQr1rOrawupperreplacer.rr/intsplitencoder)rrequest wsgi_inputrWenviron header_key header_valuekeyrNr rP status_codevaluerOrKrLrMs @@@rhandle_requestzWSGITransport.handle_request[s5 ZZ0 {{QB#=gkk>P>P#Q"&{{11$++9szz $!&"%nn++ ))#KK--44W=";;++t9)++ ")0(;(; 8 $J ##G,224<2'&&&$000 ]1-$2K2K" "+++-a01 4 UZZ %,,w"7 8   WVDD  s:,H7)Tz 127.0.0.1N) r.r r/boolr0rQr1rQr2ztyping.TextIO | Noner&r')rfrr&r)r(r)r*__doc__r!rnr+rrr r ,s[F&*&,0 '  '# ' '  ' * '  ':Er)rtyping.Iterable[_T]r&rr) __future__rrSrrYtyping_modelsrr_typesrbaser TYPE_CHECKING _typeshedr _typeshed.wsgir TypeVarr __all__rrr r+rrr}sg"  '# $.V^^D   ^ iEMiEr