\d`ldZddlZgdZGddZdZdZdd Zd Zd Zhd j Z d Z dS)z$Miscellaneous WSGI-related UtilitiesN) FileWrapper guess_schemeapplication_uri request_urishift_path_infosetup_testing_defaultsc&eZdZdZddZdZdZdS)rz1Wrapper to convert file-like objects to iterables c^||_||_t|dr|j|_dSdS)Nclose)filelikeblksizehasattrr )selfr rs ..\python\lib\wsgiref\util.py__init__zFileWrapper.__init__s9   8G $ $ (!DJJJ ( (c|SN)rs r__iter__zFileWrapper.__iter__s rcV|j|j}|r|Str)r readr StopIteration)rdatas r__next__zFileWrapper.__next__s,}!!$,//  KrN)r )__name__ __module__ __qualname____doc__rrrrrrrr sL;;(((( rrc8|ddvrdSdS)zMReturn a guess for whether 'wsgi.url_scheme' should be 'http' or 'https' HTTPS)yeson1httpshttp)get)environs rrrs&{{7///wvrcL|ddz}ddlm}|dr ||dz }nL||dz }|ddkr|dd kr|d |dzz }n|dd kr|d |dzz }|||d pd 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""""""{{; 4 w{## w}%% $ % 0 0}%..sW]333}%--sW]33355]++2sX F F FFC JrTct|}ddlm}||dddd}|ds||d d z }n||z }|r#|d r|d |d zz }|S) zBReturn the full request URI, optionally including the query stringrr, PATH_INFOz/;=,r6)safer7r4N QUERY_STRING?)rr8r-r()r) include_queryr9r- path_infos rrr9s ' " "C""""""gkk+b11RRRI ;;} % % y} y-^44- sW^,,, Jrc|dd}|sdS|d}d|ddD|dd<|d}|d=|dd}tj|dz|z}|dr |dd}|s|ds|dz }||d<d||d<|d krd}|S) 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<Nr5c"g|] }||dk | S).r).0ps r z#shift_path_info..Xs"FFFaqFQ#XXXXXrr>r4rE)r(split posixpathnormpathendswithjoin)r)rB path_partsname script_names rrrFs K++I t%%JFF:ad#3FFFJqt a=D1 ++mB//K$[_T%9::KC  '!#2#&  ,,S11s (GM XXj11GK Syy Krc8|dd|dd|d|d|ddd|vr0d |vr,|dd |d d |d d |dd|dd|ddddlm}m}|d||d||dt ||ddkr|dddS|ddkr|dddSdS)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_METHODGETr4r;r<r5z wsgi.version)r>rz wsgi.run_oncerzwsgi.multithreadzwsgi.multiprocess)StringIOBytesIOz wsgi.inputz wsgi.errorsr+r'r0r3r&r1N) setdefaultiorVrWr)r)rVrWs rrros }[111 (444 {7=#9::: '...G## 7(B(B=,,,;s+++ ~u--- *** )1--- *A...$$$$$$$$ |WWYY/// }hhjj111 (g)>)>??? !6))=$///// " #W , ,=%00000 - ,r> keep-alivetransfer-encodingproxy-authenticateproxy-authorizationteupgradetrailers connectioncDt|S)z?Return true if 'header_name' is an HTTP/1.1 "Hop-by-Hop" header)_hoppishlower) header_names r is_hop_by_hoprfs K%%'' ( ((r)T) r rK__all__rrrrrr __contains__rcrfrrrris**    $(    '''R$1$1$1P     )))))r