
    F\hq                     p    S r SSKr/ SQr " S S5      rS rS rSS jrS	 rS
 r1 SkR                  r
S rg)z$Miscellaneous WSGI-related Utilities    N)FileWrapperguess_schemeapplication_urirequest_urishift_path_infosetup_testing_defaultsis_hop_by_hopc                   .    \ rS rSrSrSS jrS rS rSrg)	r      z1Wrapper to convert file-like objects to iterablesc                 b    Xl         X l        [        US5      (       a  UR                  U l        g g )Nclose)filelikeblksizehasattrr   )selfr   r   s      #/usr/lib/python3.13/wsgiref/util.py__init__FileWrapper.__init__   s)     8G$$!DJ %    c                     U $ N )r   s    r   __iter__FileWrapper.__iter__   s    r   c                 j    U R                   R                  U R                  5      nU(       a  U$ [        er   )r   readr   StopIteration)r   datas     r   __next__FileWrapper.__next__   s(    }}!!$,,/Kr   )r   r   r   N)i    )	__name__
__module____qualname____firstlineno____doc__r   r   r   __static_attributes__r   r   r   r   r      s    ;(r   r   c                 0    U R                  S5      S;   a  gg)zMReturn a guess for whether 'wsgi.url_scheme' should be 'http' or 'https'
    HTTPS)yeson1httpshttp)get)environs    r   r   r      s     {{7//r   c                    U S   S-   nSSK Jn  U R                  S5      (       a  XS   -  nO9XS   -  nU S   S:X  a  U S   S	:w  a  US
U S   -   -  nOU S   S:w  a  US
U S   -   -  nX" U R                  S5      =(       d    SSS9-  nU$ )z@Return the application's base URI (no PATH_INFO or QUERY_STRING)wsgi.url_schemez://r   quote	HTTP_HOSTSERVER_NAMEr,   SERVER_PORT443:80SCRIPT_NAME/latin1)encoding)urllib.parser3   r.   )r/   urlr3   s      r   r   r   %   s    
#
$U
*C"{{;{##}%%$%0}%.sW]333}%-sW]3335]+2sXFFCJr   c                     [        U 5      nSSKJn  U" U R                  SS5      SSS9nU R                  S5      (       d  X$S	S
 -  nOX$-  nU(       a!  U R                  S5      (       a  USU S   -   -  nU$ )zBReturn the full request URI, optionally including the query stringr   r2   	PATH_INFO z/;=,r<   )safer=   r:      NQUERY_STRING?)r   r>   r3   r.   )r/   include_queryr?   r3   	path_infos        r   r   r   9   sw    
'
"C"gkk+b1RI;;}%%}^44sW^,,,Jr   c                    U R                  SS5      nU(       d  gUR                  S5      nUSS  Vs/ s H  o3(       d  M  US:w  d  M  UPM     snUSS& US   nUS	 U R                  SS5      n[        R                  " US-   U-   5      nUR	                  S5      (       a  USS nU(       d  UR	                  S5      (       d  US-  nXPS'   SR                  U5      U S'   US:X  a  SnU$ s  snf )	a6  Shift 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.
rA   rB   Nr;   rD   .r:   )r.   split	posixpathnormpathendswithjoin)r/   rH   
path_partspnamescript_names         r   r   r   F   s     K+I%J#-a#3F#3aqQ#X#3FJqa=D1++mB/K$$[_T%9:KC  !#2&,,S11s(M XXj1GK SyK+ Gs   
C*C*	C*c                    U R                  SS5        U R                  SS5        U R                  SU S   5        U R                  SS5        SU ;  a*  S	U ;  a$  U R                  SS
5        U R                  S	S5        U R                  SS5        U R                  SS5        U R                  SS5        U R                  SS5        SSKJnJn  U R                  SU" 5       5        U R                  SU" 5       5        U R                  S[	        U 5      5        U S   S:X  a  U R                  SS5        gU S   S:X  a  U R                  SS5        gg)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!
r5   z	127.0.0.1SERVER_PROTOCOLzHTTP/1.0r4   REQUEST_METHODGETr:   rA   rB   r;   zwsgi.version)rD   r   zwsgi.run_oncer   zwsgi.multithreadzwsgi.multiprocess)StringIOBytesIOz
wsgi.inputzwsgi.errorsr1   r-   r6   r9   r,   r7   N)
setdefaultiorY   rZ   r   )r/   rY   rZ   s      r   r   r   o   s:    }[1(4{7=#9:'.G#7(B=,;s+~u-*)1-*A.$|WY/}hj1(g)>? !6)=$/	"	#W	,=%0 
-r   >   teupgradetrailers
connection
keep-alivetransfer-encodingproxy-authenticateproxy-authorizationc                 4    [        U R                  5       5      $ )z?Return true if 'header_name' is an HTTP/1.1 "Hop-by-Hop" header)_hoppishlower)header_names    r   r	   r	      s    K%%'((r   )T)r%   rM   __all__r   r   r   r   r   r   __contains__rf   r	   r   r   r   <module>rk      sM    *  $('R$1P ,	 	)r   