xL i}JddlmZddlZddlmZmZddlmZddlm Z ejr-ddl Z ddl Z eje je jfZejeej"fZej&gej(efZej&ejeej"fgej(dfZej&ejeej"feegej(dfZdgZdd Zdd ZGd d eZGd de Zy)) annotationsN)RequestResponse)AsyncByteStream)AsyncBaseTransport ASGITransportcV ddl}|jdk(ry y#t$rYywxYw)NrtrioTF)sniffiocurrent_async_library ImportError)r s \/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/httpx/_transports/asgi.pyis_running_triorsA     ( ( *f 4 5     s  ((cjtrddl}|jSddl}|jS)Nr)rr Eventasyncio)r rs r create_eventr,s*tzz| 7==?ceZdZddZddZy)ASGIResponseStreamc||_yN)_body)selfbodys r__init__zASGIResponseStream.__init__8s  rcHKdj|jyw)Nr)joinr)rs r __aiter__zASGIResponseStream.__aiter__;shhtzz""s "N)rz list[bytes]returnNone)r"ztyping.AsyncIterator[bytes])__name__ __module__ __qualname__rr!rrrr7s #rrcBeZdZdZ d ddZ ddZy)r a A custom AsyncTransport that handles sending requests directly to an ASGI app. ```python transport = httpx.ASGITransport( app=app, root_path="/submount", client=("1.2.3.4", 123) ) client = httpx.AsyncClient(transport=transport) ``` 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. * `root_path` - The root path on which the ASGI application should be mounted. * `client` - A two-tuple indicating the client IP and port of incoming requests. ``` c<||_||_||_||_yr)appraise_app_exceptions root_pathclient)rr*r+r,r-s rrzASGITransport.__init__Ws!$8!" rc  KtjtsJdddidjjj Dcgc]\}}|j |fc}}jjjjjjjddjjjjjjf|j|j d }jj# d dd gd t% d fd }d fd } |j'|||d{ j/sJJ Jt1}t3 | Scc}}w7=#t($r(|j*r j-d  i YkwxYww)Nhttpversionz3.0z1.1?r) typeasgi http_versionmethodheadersschemepathraw_path query_stringserverr-r,FcKrjd{ddiS jd{}d|ddS7'7 #t$r dddddcYSwxYww)Nr2zhttp.disconnectTz http.requestrF)r2r more_body)wait __anext__StopAsyncIteration)rrequest_body_chunksrequest_completeresponse_completes rreceivez3ASGITransport.handle_async_request..receives~ ',,... 122 Q0::<<+DtL L/=% Q#' .%PP QsAAAAAAAAAAAAAcBK|ddk(rrJ|d|jdgdy|ddk(rljrJ|jdd}|jd d }|r jd k7rj||sj yyyw) Nr2zhttp.response.startstatusr6Tzhttp.response.bodyrrr=FHEAD)getis_setr5appendset) messagerr= body_partsrequestrCresponse_headersresponse_started status_codes rsendz0ASGITransport.handle_async_request..sendsv"77+++%h/ #*;;y"#= #' $88,33555{{63/#KK U; GNNf4%%d+ %))+!9sBBi)r6stream)r"zdict[str, typing.Any])rLz&typing.MutableMapping[str, typing.Any]r"r#) isinstancerSrr5r6rawlowerurlr7r8r9splitqueryhostportr-r,r!rr* Exceptionr+rKrIrr)rrNkvscoperDrRrSrMrArBrCrOrPrQs ` @@@@@@@rhandle_async_requestz"ASGITransport.handle_async_requestcs'../:::&!nn5<__5H5HI6AqAIkk((KK$$ ,,2248;#KK--{{'')9)9:kk   &nn668    (N M , ,* &((5'40 0 0!'')))&&&+++#J/ -=fMMYJv 1 &((  ! ! #"! '#%  &sIAG%F),C.G%F11F/2F169G%/F11.G"G%!G""G%N)T)z 127.0.0.1{) r*_ASGIAppr+boolr,strr-ztuple[str, int]r"r#)rNrr"r)r$r%r&__doc__rr`r'rrr r ?sd4&*"4   #      XNXN XNr)r"rd)r"r) __future__rtyping_modelsrr_typesrbaser TYPE_CHECKINGrr UnionrMutableMappingreAny_MessageCallable Awaitable_Receive_Sendrc__all__rrrr r'rrrvs" '$$  LL 2 3E  fjj 1 ??2v//99 : 3 ?+,f.>.>t.DD  ?? 3 ?+Xu=v?O?OPT?UU    ##|N&|Nr