
    g                         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y)    )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y)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                 d    |j                   | _        |j                  | _        d| _        || _        y )Nr   )read_readreadline	_readline_poslimit)selfstreamr   s      q/var/www/python.vincentserveurtest.ovh/public_html/venv/lib/python3.12/site-packages/django/core/handlers/wsgi.py__init__zLimitedStream.__init__   s&    [[
	
    c                    | j                   }| j                  }||k\  ry|dk(  s|||z
  }nt        |||z
        }| j                  |      }| xj                   t	        |      z  c_         |S Nr   )r   r   minr   len)r   sizer   r   datas        r   r   zLimitedStream.read   sg    yy

5=2:4<DtUT\*Dzz$		SY	r   c                    | j                   }| j                  }||k\  ry|dk(  s|||z
  }nt        |||z
        }| j                  |      }| xj                   t	        |      z  c_         |S r   )r   r   r   r   r    )r   r!   r   r   lines        r   r   zLimitedStream.readline*   sg    yy

5=2:4<DtUT\*D~~d#		SY	r   N)r   )__name__
__module____qualname____doc__r   r   r    r   r   r   r      s    r   r   c                   f    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y)	WSGIRequestc                    t        |      }t        |      xs d}|| _        || _        |j	                  d      d|j                  ddd      | _        || _        || j                  d<   || j                  d<   |d   j                         | _	        | j                  |       	 t        |j                  d            }t        | j                  d	   |      | _        d
| _        d | _        y # t        t        f$ r d}Y @w xY w)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	8I8I#rST8UV		!*		+#.		- ./557%%g.	 -=!>?N %T\\,%?P""	 I& 	N	s   $C+ +C?>C?c                 8    | j                   j                  d      S )Nzwsgi.url_scheme)r6   r@   r   s    r   _get_schemezWSGIRequest._get_schemeR   s    || 122r   c                 ^    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)DNNCCr   c                 R    t        | d      s| j                          | j                  S )N_post)hasattr_load_post_and_filesrS   rI   s    r   	_get_postzWSGIRequest._get_post[   s"    tW%%%'zzr   c                     || _         y N)rS   )r   posts     r   	_set_postzWSGIRequest._set_post`   s	    
r   c                 F    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
J''r   c                 R    t        | d      s| j                          | 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   sb    #23 D D

 ( (  
 Iy)Dr   r+   c                   (     e Zd ZeZ fdZd Z xZS )WSGIHandlerc                 D    t        |   |i | | j                          y rX   )superr   load_middleware)r   argskwargs	__class__s      r   r   zWSGIHandler.__init__t   s!    $)&)r   c                 J   t        t        |             t        j                  j	                  | j
                  |       | j                  |      }| j                  |      }| j
                  |_        d|j                  |j                  fz  }g |j                         d |j                  j                         D        } |||       t        |dd       L|j                  d      r;|j                   |j"                  _         |d   |j"                  |j$                        }|S )N)senderr6   z%d %sc              3   D   K   | ]  }d |j                  d      f  yw)z
Set-Cookier.   )headerN)output).0cs     r   	<genexpr>z'WSGIHandler.__call__.<locals>.<genexpr>   s#     U;Ta|QXXRX01;Ts    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   s   /'23$$DNNG$L$$W-$$W-"&..H00(2H2HII
^^
U8;K;K;R;R;TU
 	v/08-t4@W[[F
 -5NNH##)3w23'')<)<H r   )r%   r&   r'   r+   rx   r   r   __classcell__)rl   s   @r   rf   rf   q   s    Mr   rf   c                 N    t        | dd      }t        |      j                         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7r   c                 H   t         j                  t         j                  S t        | dd      xs t        | dd      }|rHd|v rt        j	                  d|      }t        | dd      }|j                  |      }|j                         S t        | dd      }|j                         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).
    
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J J %z:J'bA	 --i8  *'="Er   c                 H    | j                  ||      }|j                  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                 @    t        | ||      }|j                  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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      so        % < < ) : 3 6v&&F &R6*+ 6*r$"" D8 B
&*r   