
    Evg                        d dl mZ d dlmZ d dlmZ d dlmZ d dlm	Z	m
Z
mZ d dlmZ d dlmZ d dlmZ d d	lmZ  ed
          Z G d de          Z G d de	          Z G d dej                  Zd Zd Zd Zd ZdS )    )IOBase)settings)signals)base)HttpRequest	QueryDictparse_cookie)set_script_prefix)repercent_broken_unicode)cached_property)_lazy_re_compiles   /+c                   (    e Zd ZdZd ZddZddZdS )LimitedStreamz
    Wrap another stream to disallow reading it past a number of bytes.

    Based on the implementation from werkzeug.wsgi.LimitedStream
    See https://github.com/pallets/werkzeug/blob/dbf78f67/src/werkzeug/wsgi.py#L828
    c                 R    |j         | _        |j        | _        d| _        || _        d S )Nr   )read_readreadline	_readline_poslimit)selfstreamr   s      V/var/www/pixelcanvas.ch/venv/lib/python3.11/site-packages/django/core/handlers/wsgi.py__init__zLimitedStream.__init__   s&    [
	


    c                    | j         }| j        }||k    rdS |dk    s|||z
  }nt          |||z
            }|                     |          }| xj         t	          |          z  c_         |S Nr   r   )r   r   minr   len)r   sizer   r   datas        r   r   zLimitedStream.read   su    y
5==32::4<DDtUT\**Dzz$		SYY		r   c                    | j         }| j        }||k    rdS |dk    s|||z
  }nt          |||z
            }|                     |          }| xj         t	          |          z  c_         |S r   )r   r   r   r   r    )r   r!   r   r   lines        r   r   zLimitedStream.readline*   su    y
5==32::4<DDtUT\**D~~d##		SYY		r   N)r   )__name__
__module____qualname____doc__r   r   r    r   r   r   r      sU                   r   r   c                       e Zd Zd Zd Zed             Zd Zd Zed             Z	e
d             Z e
ee          ZdS )	WSGIRequestc                 >   t          |          }t          |          pd}|| _        || _        |                    d          d|                    ddd          | _        || _        || j        d<   || j        d<   |d                                         | _	        | 
                    |           	 t          |                    d                    }n# t          t          f$ r d}Y nw xY wt          | j        d	         |          | _        d
| _        d | _        d S )N/    	PATH_INFOSCRIPT_NAMEREQUEST_METHODCONTENT_LENGTHr   z
wsgi.inputF)get_script_nameget_path_infoenviron	path_inforstripreplacepathMETAuppermethod_set_content_type_paramsintget
ValueError	TypeErrorr   _stream_read_startedresolver_match)r   r6   script_namer7   content_lengths        r   r   zWSGIRequest.__init__9   s-   %g.. "'**1c	"  +11#6666	8I8I#rST8U8U8UV		!*	+#.	- ./5577%%g...	 -=!>!>??NNI& 	 	 	NNN	$T\,%?PP""s   3"C C,+C,c                 6    | j                             d          S )Nzwsgi.url_scheme)r6   r@   r   s    r   _get_schemezWSGIRequest._get_schemeR   s    | 1222r   c                 Z    t          | j        dd          }t          || j                  S )NQUERY_STRINGr.   )encoding)get_bytes_from_wsgir6   r   	_encoding)r   raw_query_strings     r   GETzWSGIRequest.GETU   s.     /t|^RPP)DNCCCCr   c                 X    t          | d          s|                                  | j        S )N_post)hasattr_load_post_and_filesrS   rI   s    r   	_get_postzWSGIRequest._get_post[   s.    tW%% 	(%%'''zr   c                     || _         d S N)rS   )r   posts     r   	_set_postzWSGIRequest._set_post`   s    


r   c                 L    t          | j        dd          }t          |          S )NHTTP_COOKIEr.   )get_str_from_wsgir6   r	   )r   
raw_cookies     r   COOKIESzWSGIRequest.COOKIESc   s#    &t|]BGG
J'''r   c                 X    t          | d          s|                                  | j        S )N_files)rT   rU   ra   rI   s    r   FILESzWSGIRequest.FILESh   s.    tX&& 	(%%'''{r   N)r%   r&   r'   r   rJ   r   rQ   rV   rZ   r_   propertyrb   POSTr)   r   r   r+   r+   8   s        # # #23 3 3 D D _D
  
   ( ( _(   X
 8Iy))DDDr   r+   c                   (     e Zd ZeZ fdZd Z xZS )WSGIHandlerc                 b     t                      j        |i | |                                  d S rX   )superr   load_middleware)r   argskwargs	__class__s      r   r   zWSGIHandler.__init__t   s7    $)&)))r   c                 H   t          t          |                     t          j                            | j        |           |                     |          }|                     |          }| j        |_        d|j	        |j
        fz  }g |                                d |j                                        D             } |||           t          |dd           B|                    d          r-|j        |j        _         |d         |j        |j                  }|S )N)senderr6   z%d %sc              3   F   K   | ]}d |                     d          fV  dS )z
Set-Cookier.   )headerN)output).0cs     r   	<genexpr>z'WSGIHandler.__call__.<locals>.<genexpr>   s5      UUa|QXXRX001UUUUUUr   file_to_streamzwsgi.file_wrapper)r
   r4   r   request_startedsendrl   request_classget_response_handler_classstatus_codereason_phraseitemscookiesvaluesgetattrr@   closeru   
block_size)r   r6   start_responserequestresponsestatusresponse_headerss          r   __call__zWSGIHandler.__call__x   s2   /'22333$$DNG$LLL$$W--$$W--"&.H0(2HII
^^
UU8;K;R;R;T;TUUU
 	v/0008-t44@W[[F
 F
@ -5NH#)3w23')< H r   )r%   r&   r'   r+   rx   r   r   __classcell__)rl   s   @r   rf   rf   q   sL        M          r   rf   c                 f    t          | dd          }t          |                                          S )z0Return the HTTP request's PATH_INFO as a string.r0   r-   )rN   r   decode)r6   r7   s     r   r5   r5      s-    #G[#>>I#I..55777r   c                 P   t           j        t           j        S t          | dd          pt          | dd          }|rFd|v rt                              d|          }t          | dd          }|                    |          }nt          | dd          }|                                S )	aE  
    Return the equivalent of the HTTP request's SCRIPT_NAME environment
    variable. If Apache mod_rewrite is used, return what would have been
    the script name prior to any rewriting (so it's the script name as seen
    from the client's perspective), unless the FORCE_SCRIPT_NAME setting is
    set (to anything).
    N
SCRIPT_URLr.   REDIRECT_URLs   //   /r0   r1   )r   FORCE_SCRIPT_NAMErN   _slashes_resubremovesuffixr   )r6   
script_urlr7   rF   s       r   r4   r4      s     !-)) %WlB?? CVD DJ  FJ %z::J'bAA	 --i88)'="EEr   c                 X    |                      ||          }|                    d          S )zh
    Get a value from the WSGI environ dictionary as bytes.

    key and default should be strings.
    z
iso-8859-1)r@   encoder6   keydefaultvalues       r   rN   rN      s+     KKW%%E <<%%%r   c                 P    t          | ||          }|                    d          S )zj
    Get a value from the WSGI environ dictionary as str.

    key and default should be str objects.
    r9   )errors)rN   r   r   s       r   r]   r]      s)      g66E<<y<)))r   N)ior   django.confr   django.corer   django.core.handlersr   django.httpr   r   r	   django.urlsr
   django.utils.encodingr   django.utils.functionalr   django.utils.regex_helperr   r   r   r+   BaseHandlerrf   r5   r4   rN   r]   r)   r   r   <module>r      s                           % % % % % % < < < < < < < < < < ) ) ) ) ) ) : : : : : : 3 3 3 3 3 3 6 6 6 6 6 6v&&& & & & &F & & &R6* 6* 6* 6* 6*+ 6* 6* 6*r    $"   D8 8 8     B
& 
& 
&* * * * *r   