Plan 9 from Bell Labs’s /usr/web/sources/contrib/stallion/root/sys/lib/python2.7/wsgiref/util.pyc

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


�`^c@s�dZddlZddddddgZddd	��YZd
�Zd�Zdd
�Zd�Zd�Zidd6dd6dd6dd6dd6dd6dd6dd6j	Z
d�ZdS(s$Miscellaneous WSGI-related Utilitiesi�NtFileWrappertguess_schemetapplication_uritrequest_uritshift_path_infotsetup_testing_defaultscBs5eZdZdd�Zd�Zd�Zd�ZRS(s1Wrapper to convert file-like objects to iterablesi cCs4||_||_t|d�r0|j|_ndS(Ntclose(tfileliketblksizethasattrR(tselfRR((s"/sys/lib/python2.7/wsgiref/util.pyt__init__s		cCs)|jj|j�}|r|St�dS(N(RtreadRt
IndexError(R
tkeytdata((s"/sys/lib/python2.7/wsgiref/util.pyt__getitem__scCs|S(N((R
((s"/sys/lib/python2.7/wsgiref/util.pyt__iter__scCs)|jj|j�}|r|St�dS(N(RRRt
StopIteration(R
R((s"/sys/lib/python2.7/wsgiref/util.pytnexts(t__name__t
__module__t__doc__RRRR(((s"/sys/lib/python2.7/wsgiref/util.pyRs
		cCs!|jd�dkrdSdSdS(	sMReturn a guess for whether 'wsgi.url_scheme' should be 'http' or 'https'
    tHTTPStyestont1thttpsthttpN(RRR(tget(tenviron((s"/sys/lib/python2.7/wsgiref/util.pyR#scCs�|dd}ddlm}|jd�r>||d7}nk||d7}|ddkr�|dd	kr�|d
|d7}q�n%|ddkr�|d
|d7}n|||jd�p�d
�7}|S(s@Return the application's base URI (no PATH_INFO or QUERY_STRING)swsgi.url_schemes://i�(tquotet	HTTP_HOSTtSERVER_NAMERtSERVER_PORTt443t:t80tSCRIPT_NAMEt/(turllibRR(RturlR((s"/sys/lib/python2.7/wsgiref/util.pyR+sicCs�t|�}ddlm}||jdd�dd�}|jd�sZ||d7}n
||7}|r�|jd	�r�|d
|d	7}n|S(sBReturn the full request URI, optionally including the query stringi�(Rt	PATH_INFOttsafes/;=,R&itQUERY_STRINGt?(RR(RR(Rt
include_queryR)Rt	path_info((s"/sys/lib/python2.7/wsgiref/util.pyR?s
cCs|jdd�}|sdS|jd�}g|dd!D]}|r9|dkr9|^q9|dd+|d}|d=|jdd�}tj|d|�}|jd�r�|d }n|r�|jd�r�|d7}n||d<dj|�|d<|dkrd}n|S(	sZShift 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+R'ii�t.R&N(RtNonetsplitt	posixpathtnormpathtendswithtjoin(RR0t
path_partstptnametscript_name((s"/sys/lib/python2.7/wsgiref/util.pyRLs$
9



	cCsX|jdd�|jdd�|jd|d�|jdd�d|krd	|kr|jdd
�|jd	d�n|jdd�|jdd�|jdd�|jdd�ddlm}|jd|d
��|jd|��|jdt|��|ddkr1|jdd�n#|ddkrT|jdd�ndS(s: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!s	127.0.0.1tSERVER_PROTOCOLsHTTP/1.0R tREQUEST_METHODtGETR&R*R+R'swsgi.versioniis
wsgi.run_onceswsgi.multithreadswsgi.multiprocessi�(tStringIOs
wsgi.inputswsgi.errorsswsgi.url_schemeRR"R%RR#N(ii(t
setdefaultR?R(RR?((s"/sys/lib/python2.7/wsgiref/util.pyRus&
t
connections
keep-alivesproxy-authenticatesproxy-authorizationttettrailersstransfer-encodingtupgradecCst|j��S(s?Return true if 'header_name' is an HTTP/1.1 "Hop-by-Hop" header(t_hoppishtlower(theader_name((s"/sys/lib/python2.7/wsgiref/util.pyt
is_hop_by_hop�s((RR4t__all__RRRRRRt__contains__RERH(((s"/sys/lib/python2.7/wsgiref/util.pyt<module>s		
	)	(


Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to [email protected].