f`ndZddlZgdZGddZdZdZd dZd Zd Zhd jZ d Z y)z$Miscellaneous WSGI-related UtilitiesN) FileWrapper guess_schemeapplication_uri request_urishift_path_infosetup_testing_defaultsc$eZdZdZddZdZdZy)rz1Wrapper to convert file-like objects to iterablesc\||_||_t|dr|j|_yy)Nclose)filelikeblksizehasattrr )selfr r s #/usr/lib/python3.12/wsgiref/util.py__init__zFileWrapper.__init__s*   8G $!DJ %c|SN)rs r__iter__zFileWrapper.__iter__s rc`|jj|j}|r|Str)r readr StopIteration)rdatas r__next__zFileWrapper.__next__s(}}!!$,,/ KrN)i )__name__ __module__ __qualname____doc__rrrrrrrr s;( rrc,|jddvryy)zMReturn a guess for whether 'wsgi.url_scheme' should be 'http' or 'https' HTTPS)yeson1httpshttp)get)environs rrrs{{7//rc|ddz}ddlm}|jdr ||dz }n7||dz }|ddk(r|dd k7r|d |dzz }n|dd k7r |d |dzz }|||jd xsd dz }|S)z@Return the application's base URI (no PATH_INFO or QUERY_STRING)wsgi.url_schemez://rquote HTTP_HOST SERVER_NAMEr% SERVER_PORT443:80 SCRIPT_NAME/latin1)encoding) urllib.parser,r')r(urlr,s rrr%s # $U *C"{{; w{## w}%% $ % 0}%.sW]333}%-sW]3335]+2sX FFC Jrct|}ddlm}||jdddd}|jds ||d d z }n||z }|r|jd r |d |d zz }|S) zBReturn the full request URI, optionally including the query stringrr+ PATH_INFOz/;=,r5)safer6r3N QUERY_STRING?)rr7r,r')r( include_queryr8r, path_infos rrr9su ' "C"gkk+b1RI ;;} % y} y^4 sW^,,, Jrc|jdd}|sy|jd}|ddDcgc] }|s|dk7s |c}|dd|d}|d=|jdd}tj|dz|z}|j dr|dd}|s|j ds|dz }||d<dj ||d<|dk(rd}|Scc}w) aZShift a name from PATH_INFO to SCRIPT_NAME, returning it If there are no remaining path segments in PATH_INFO, return None. Note: 'environ' is modified in-place; use a copy if you need to keep the original PATH_INFO or SCRIPT_NAME. Note: when PATH_INFO is just a '/', this returns '' and appends a trailing '/' to SCRIPT_NAME, even though empty path segments are normally ignored, and SCRIPT_NAME doesn't normally end in a '/'. This is intentional behavior, to ensure that an application can tell the difference between '/x' and '/x/' when traversing to objects. r:r;Nr4r=.r3)r'split posixpathnormpathendswithjoin)r(rA path_partspname script_names rrrFs K+I %J#-a#3FaqQ#XFJq a=D1 ++mB/K$$[_T%9:KC !#2&  ,,S1s (GM XXj1GK Sy K+GsC C C c|jdd|jdd|jd|d|jddd|vr(d |vr$|jdd |jd d |jd d |jdd|jdd|jddddlm}m}|jd||jd||jdt ||ddk(r|jddy|ddk(r|jddyy)a:Update 'environ' with trivial defaults for testing purposes This adds various parameters required for WSGI, including HTTP_HOST, SERVER_NAME, SERVER_PORT, REQUEST_METHOD, SCRIPT_NAME, PATH_INFO, and all of the wsgi.* variables. It only supplies default values, and does not replace any existing settings for these variables. This routine is intended to make it easier for unit tests of WSGI servers and applications to set up dummy environments. It should *not* be used by actual WSGI servers or applications, since the data is fake! r.z 127.0.0.1SERVER_PROTOCOLzHTTP/1.0r-REQUEST_METHODGETr3r:r;r4z wsgi.version)r=rz wsgi.run_oncerzwsgi.multithreadzwsgi.multiprocess)StringIOBytesIOz wsgi.inputz wsgi.errorsr*r&r/r2r%r0N) setdefaultiorRrSr)r(rRrSs rrros: }[1 (4 {7=#9: '.G# 7(B=,;s+ ~u- * )1- *A.$ |WY/ }hj1 (g)>? !6)=$/ " #W ,=%0 -r> keep-alivetransfer-encodingproxy-authenticateproxy-authorizationteupgradetrailers connectionc4t|jS)z?Return true if 'header_name' is an HTTP/1.1 "Hop-by-Hop" header)_hoppishlower) header_names r is_hop_by_hoprbs K%%' ((r)T) rrF__all__rrrrrr __contains__r_rbrrrresM*  $( 'R$1P ,  )r