Sindbad~EG File Manager

Current Path : /usr/local/lib/python3.12/site-packages/werkzeug/__pycache__/
Upload File :
Current File : //usr/local/lib/python3.12/site-packages/werkzeug/__pycache__/wsgi.cpython-312.pyc

�

'ٜg�Q���ddlmZddlZddlZddlmZddlmZddlm	Z	ddlm
Z
ddlmZ
dd	lmZej rdd
lmZddlmZdd�Z				d											dd
�Z				dd�Z	d 					d!d�Zd"d�Z		d#							d$d�Zd%d�ZGd�d�Z	d&							d'd�ZGd�d�ZGd�d�ZGd�dej>�Z y)(�)�annotationsN)�partial��update_wrapper�)�ClientDisconnected)�RequestEntityTooLarge)�utils)�host_is_trusted)�WSGIApplication)�WSGIEnvironmentc�"��t�fd���S)a
Marks a function as responder.  Decorate a function with it and it
    will automatically call the return value as WSGI application.

    Example::

        @responder
        def application(environ, start_response):
            return Response('Hello World!')
    c����|�|dd�S)N����)�a�fs ��8/usr/local/lib/python3.12/site-packages/werkzeug/wsgi.py�<lambda>zresponder.<locals>.<lambda>s���U�Q��U�A�b�c�F�^�r)rs`r�	responderrs����3�Q�7�7rc��|dt||�d�}|sR|jdd�|d<|s;|jdd�|d<|s$|jdd�jd	�|d
<tjdi|��S)aXRecreate the URL for a request from the parts in a WSGI
    environment.

    The URL is an IRI, not a URI, so it may contain Unicode characters.
    Use :func:`~werkzeug.urls.iri_to_uri` to convert it to ASCII.

    :param environ: The WSGI environment to get the URL parts from.
    :param root_only: Only build the root path, don't include the
        remaining path or query string.
    :param strip_querystring: Don't include the query string.
    :param host_only: Only build the scheme and host.
    :param trusted_hosts: A list of trusted host names to validate the
        host against.
    �wsgi.url_scheme)�scheme�host�SCRIPT_NAME��	root_path�	PATH_INFO�path�QUERY_STRING�latin1�query_stringr)�get_host�get�encode�
_sansio_utils�get_current_url)�environ�	root_only�strip_querystring�	host_only�
trusted_hosts�partss      rr(r(s���,�+�,���-�0�
�E�
�$�[�[���;��k���#�K�K��R�8�E�&�M�$�(/���N�B�(G�(N�(N�x�(X��n�%��(�(�1�5�1�1rc��|jd�}|�y	t|jdd��}||fS#ttf$rd}Y||fSwxYw)N�SERVER_NAME�SERVER_PORT)r%�int�	TypeError�
ValueError)r)�name�ports   r�_get_serverr7Ese���;�;�}�%�D��|����w�{�{�=�$�?�@��
��:���	
�z�"������:��	�s�5�A�Ac�h�tj|d|jd�t|�|�S)arReturn the host for the given WSGI environment.

    The ``Host`` header is preferred, then ``SERVER_NAME`` if it's not
    set. The returned host will only contain the port if it is different
    than the standard port for the protocol.

    Optionally, verify that the host is trusted using
    :func:`host_is_trusted` and raise a
    :exc:`~werkzeug.exceptions.SecurityError` if it is not.

    :param environ: A WSGI environment dict.
    :param trusted_hosts: A list of trusted host names.

    :return: Host, with port if necessary.
    :raise ~werkzeug.exceptions.SecurityError: If the host is not
        trusted.
    r�	HTTP_HOST)r'r$r%r7)r)r-s  rr$r$Vs7��(�!�!��!�"����K� ��G���	�rc�l�tj|jd�|jd���S)adReturn the ``Content-Length`` header value as an int. If the header is not given
    or the ``Transfer-Encoding`` header is ``chunked``, ``None`` is returned to indicate
    a streaming request. If the value is not an integer, or negative, 0 is returned.

    :param environ: The WSGI environ to get the content length from.

    .. versionadded:: 0.9
    �CONTENT_LENGTH�HTTP_TRANSFER_ENCODING)�http_content_length�http_transfer_encoding)r'�get_content_lengthr%)r)s rr?r?rs1���+�+�#�K�K�(8�9�&�{�{�+C�D��rc��tjtjt|d�}t	|�}|�|�||kDr
t��d|vr;|�7tjtjtt
||d���S|S|�|rtj�S|Stjtjtt
||��S)a�Return the WSGI input stream, wrapped so that it may be read safely without going
    past the ``Content-Length`` header value or ``max_content_length``.

    If ``Content-Length`` exceeds ``max_content_length``, a
    :exc:`RequestEntityTooLarge`` ``413 Content Too Large`` error is raised.

    If the WSGI server sets ``environ["wsgi.input_terminated"]``, it indicates that the
    server handles terminating the stream, so it is safe to read directly. For example,
    a server that knows how to handle chunked requests safely would set this.

    If ``max_content_length`` is set, it can be enforced on streams if
    ``wsgi.input_terminated`` is set. Otherwise, an empty stream is returned unless the
    user explicitly disables this safe fallback.

    If the limit is reached before the underlying stream is exhausted (such as a file
    that is too large, or an infinite stream), the remaining contents of the stream
    cannot be read safely. Depending on how the server handles this, clients may show a
    "connection reset" failure instead of seeing the 413 response.

    :param environ: The WSGI environ containing the stream.
    :param safe_fallback: Return an empty stream when ``Content-Length`` is not set.
        Disabling this allows infinite streams, which can be a denial-of-service risk.
    :param max_content_length: The maximum length that content-length or streaming
        requests may not exceed.

    .. versionchanged:: 2.3.2
        ``max_content_length`` is only applied to streaming requests if the server sets
        ``wsgi.input_terminated``.

    .. versionchanged:: 2.3
        Check ``max_content_length`` and raise an error if it is exceeded.

    .. versionadded:: 0.9
    z
wsgi.inputzwsgi.input_terminatedT)�is_max)	�t�cast�IO�bytesr?r	�
LimitedStream�io�BytesIO)r)�
safe_fallback�max_content_length�stream�content_lengths     r�get_input_streamrM�s���N�V�V�A�D�D��K���!6�
7�F�'��0�N��!�&8�&D��.�.�'�)�)��'�)��)��6�6����U��]�6�3E�d�S��
��
�
��,�r�z�z�|�8�&�8��6�6�!�$�$�u�+�}�V�^�D�E�Erc�h�|jdd�jd�}|jd��S)z�Return ``PATH_INFO`` from  the WSGI environment.

    :param environ: WSGI environment to get the path from.

    .. versionchanged:: 3.0
        The ``charset`` and ``errors`` parameters were removed.

    .. versionadded:: 0.9
    rrr"�replace)�errors)r%r&�decode)r)r s  r�
get_path_inforR�s0���+�+�k�2�.�5�5�h�?�D��;�;�i�;�(�(rc�>�eZdZdZ	d					dd�Zd	d�Zd
d�Zdd�Zy)�ClosingIteratoraAThe WSGI specification requires that all middlewares and gateways
    respect the `close` callback of the iterable returned by the application.
    Because it is useful to add another close action to a returned iterable
    and adding a custom iterable is a boring task this class can be used for
    that::

        return ClosingIterator(app(environ, start_response), [cleanup_session,
                                                              cleanup_locals])

    If there is just one close function it can be passed instead of the list.

    A closing iterator is not needed if the application uses response objects
    and finishes the processing if the response is started::

        try:
            return response(environ, start_response)
        finally:
            cleanup_session()
            cleanup_locals()
    Nc�(�t|�}tjtjgtftt|��|_|�g}nt|�r|g}nt|�}t|dd�}|r|jd|�||_y)N�closer)
�iterrBrC�CallablerEr�next�_next�callable�list�getattr�insert�
_callbacks)�self�iterable�	callbacks�iterator�iterable_closes     r�__init__zClosingIterator.__init__�s~����>���V�V�A�J�J�r�5�y�1�7�4��3J�K��
����I�
�i�
 �"��I��Y��I� ��7�D�9������Q��/�#��rc��|S�Nr�r`s r�__iter__zClosingIterator.__iter__�����rc�"�|j�Srg)rZrhs r�__next__zClosingIterator.__next__�s���z�z�|�rc�4�|jD]	}|��yrg)r_)r`�callbacks  rrVzClosingIterator.closes�����H��J�(rrg)ra�t.Iterable[bytes]rbz@None | (t.Callable[[], None] | t.Iterable[t.Callable[[], None]])�return�None)rprT�rprE�rprq)�__name__�
__module__�__qualname__�__doc__rerirlrVrrrrTrT�s?���2GK�	$�#�$�D�$�

�$�&��rrTc�<�|jdt�||�S)a�Wraps a file.  This uses the WSGI server's file wrapper if available
    or otherwise the generic :class:`FileWrapper`.

    .. versionadded:: 0.5

    If the file wrapper from the WSGI server is used it's important to not
    iterate over it from inside the application but to pass it through
    unchanged.  If you want to pass out a file wrapper inside a response
    object you have to set :attr:`Response.direct_passthrough` to `True`.

    More information about file wrappers are available in :pep:`333`.

    :param file: a :class:`file`-like object with a :meth:`~file.read` method.
    :param buffer_size: number of bytes for one iteration.
    zwsgi.file_wrapper)r%�FileWrapper)r)�file�buffer_sizes   r�	wrap_filer|s$��$9�7�;�;�*�K�8��k��rc�J�eZdZdZd
dd�Zdd�Zd
d�Zdd�Zdd�Zdd�Z	dd�Z
y	)rya\This class can be used to convert a :class:`file`-like object into
    an iterable.  It yields `buffer_size` blocks until the file is fully
    read.

    You should not use this class directly but rather use the
    :func:`wrap_file` function that uses the WSGI server's file wrapper
    support if it's available.

    .. versionadded:: 0.5

    If you're using this object together with a :class:`Response` you have
    to use the `direct_passthrough` mode.

    :param file: a :class:`file`-like object with a :meth:`~file.read` method.
    :param buffer_size: number of bytes for one iteration.
    c� �||_||_yrg)rzr{)r`rzr{s   rrezFileWrapper.__init__0s����	�&��rc�f�t|jd�r|jj�yy�NrV)�hasattrrzrVrhs rrVzFileWrapper.close4s#���4�9�9�g�&��I�I�O�O��'rc��t|jd�r|jj�St|jd�ryy)N�seekable�seekTF)r�rzr�rhs rr�zFileWrapper.seekable8s7���4�9�9�j�)��9�9�%�%�'�'��4�9�9�f�%��rc�d�t|jd�r|jj|�yy)Nr�)r�rzr�)r`�argss  rr�zFileWrapper.seek?s'���4�9�9�f�%��D�I�I�N�N�D�!�&rc�d�t|jd�r|jj�Sy)N�tell)r�rzr�rhs rr�zFileWrapper.tellCs$���4�9�9�f�%��9�9�>�>�#�#�rc��|Srgrrhs rrizFileWrapper.__iter__Hrjrc�h�|jj|j�}|r|St��rg)rz�readr{�
StopIteration)r`�datas  rrlzFileWrapper.__next__Ks*���y�y�~�~�d�.�.�/����K��o�rN�i )rz�t.IO[bytes]r{r2rprqrs�rp�bool)r�zt.Anyrprq)rp�
int | None)rpryrr)rtrurvrwrerVr�r�r�rirlrrrryrys*���"'���"��
�rryc�X�eZdZdZ		d
					dd�Zdd�Zd
d�Zdd�Zd
d�Zd
d�Z	dd	�Z
y)�
_RangeWrapperasThis class can be used to convert an iterable object into
    an iterable that will only yield a piece of the underlying content.
    It yields blocks until the underlying stream range is fully read.
    The yielded blocks will have a size that can't exceed the original
    iterator defined block size, but that can be smaller.

    If you're using this object together with a :class:`Response` you have
    to use the `direct_passthrough` mode.

    :param iterable: an iterable object with a :meth:`__next__` method.
    :param start_byte: byte from which read will start.
    :param byte_range: how many bytes to read.
    Nc���t|�|_||_||_d|_|�
||z|_d|_t
|d�xr|j�|_d|_y)Nrr�F)	rWra�
byte_range�
start_byte�end_byte�read_lengthr�r��end_reached)r`rar�r�s    rrez_RangeWrapper.__init__csb���X���
�$���$�����
��!�&��3�D�M������*�5�M�(�:K�:K�:M��
� ��rc��|Srgrrhs rriz_RangeWrapper.__iter__urjrc��	t|j�}|xjt|�z
c_|S#t$r	d|_�wxYw�NT)rYrar��lenr�r��r`�chunks  r�_next_chunkz_RangeWrapper._next_chunkxsI��	�����'�E�����E�
�*���L���	�#�D���	�s	�47�A	c��d}|jrT|jj|j�|jj	�|_|j
}||fS|j
|jkr*|j
�}|j
|jkr�*|�||j|j
z
d}|j}||fSrg)r�rar�r�r�r�r��r`r��contextual_read_lengths   r�_first_iterationz_RangeWrapper._first_iteration�s������=�=��M�M���t���/�#�}�}�1�1�3�D��%)�%5�%5�"��,�,�,��"�"�d�o�o�5��(�(�*���"�"�d�o�o�5�� ��d�o�o��0@�0@�@�B�C��%)�_�_�"��,�,�,rc�2�|jr
t��d}|j}|jdk(r|j�\}}|�|j	�}|j
�2|j|j
k\rd|_|d|j
|z
S|S)NrT)r�r�r�r�r�r�r�s   rrZz_RangeWrapper._next�s�������/�!���!%�!1�!1�����q� �,0�,A�,A�,C�)�E�)��=��$�$�&�E��=�=�$��)9�)9�T�]�]�)J�#�D���A�4�=�=�+A�A�B�B��rc�L�|j�}|r|Sd|_t��r�)rZr�r�r�s  rrlz_RangeWrapper.__next__�s%���
�
�����L�����o�rc�f�t|jd�r|jj�yyr�)r�rarVrhs rrVz_RangeWrapper.close�s%���4�=�=�'�*��M�M���!�+r)rN)razt.Iterable[bytes] | t.IO[bytes]r�r2r�r�)rpr�rr)rpztuple[bytes | None, int]rs)rtrurvrwrerir�r�rZrlrVrrrr�r�RsN���"�!%�	!�1�!��!��	!�$��-���"rr�c�f�eZdZdZdd
d�Zedd��Zdd�Zddd�Zdd�Z	dd�Z
dd	�Zdd
�Zdd�Z
y)rFa:Wrap a stream so that it doesn't read more than a given limit. This is used to
    limit ``wsgi.input`` to the ``Content-Length`` header value or
    :attr:`.Request.max_content_length`.

    When attempting to read after the limit has been reached, :meth:`on_exhausted` is
    called. When the limit is a maximum, this raises :exc:`.RequestEntityTooLarge`.

    If reading from the stream returns zero bytes or raises an error,
    :meth:`on_disconnect` is called, which raises :exc:`.ClientDisconnected`. When the
    limit is a maximum and zero bytes were read, no error is raised, since it may be the
    end of the stream.

    If the limit is reached before the underlying stream is exhausted (such as a file
    that is too large, or an infinite stream), the remaining contents of the stream
    cannot be read safely. Depending on how the server handles this, clients may show a
    "connection reset" failure instead of seeing the 413 response.

    :param stream: The stream to read from. Must be a readable binary IO object.
    :param limit: The limit in bytes to not read past. Should be either the
        ``Content-Length`` header value or ``request.max_content_length``.
    :param is_max: Whether the given ``limit`` is ``request.max_content_length`` instead
        of the ``Content-Length`` header value. This changes how exhausted and
        disconnect events are handled.

    .. versionchanged:: 2.3
        Handle ``max_content_length`` differently than ``Content-Length``.

    .. versionchanged:: 2.3
        Implements ``io.RawIOBase`` rather than ``io.IOBase``.
    c�<�||_d|_||_||_y)Nr)�_stream�_pos�limit�
_limit_is_max)r`rKr�rAs    rrezLimitedStream.__init__�s�������	���
�#��rc�4�|j|jk\S)z:Whether the current stream position has reached the limit.)r�r�rhs r�is_exhaustedzLimitedStream.is_exhausted�s���y�y�D�J�J�&�&rc�0�|jr
t��y)a�Called when attempting to read after the limit has been reached.

        The default behavior is to do nothing, unless the limit is a maximum, in which
        case it raises :exc:`.RequestEntityTooLarge`.

        .. versionchanged:: 2.3
            Raises ``RequestEntityTooLarge`` if the limit is a maximum.

        .. versionchanged:: 2.3
            Any return value is ignored.
        N)r�r	rhs r�on_exhaustedzLimitedStream.on_exhausted�s�����'�)�)�rNc�4�|jr|�
t��y)aCalled when an attempted read receives zero bytes before the limit was
        reached. This indicates that the client disconnected before sending the full
        request body.

        The default behavior is to raise :exc:`.ClientDisconnected`, unless the limit is
        a maximum and no error was raised.

        .. versionchanged:: 2.3
            Added the ``error`` parameter. Do nothing if the limit is a maximum and no
            error was raised.

        .. versionchanged:: 2.3
            Any return value is ignored.
        N)r�r)r`�errors  r�
on_disconnectzLimitedStream.on_disconnect�s ���!�!�U�%6�$�&�&�&7rc�<�|js|j�Sy)a>Exhaust the stream by reading until the limit is reached or the client
        disconnects, returning the remaining data.

        .. versionchanged:: 2.3
            Return the remaining data.

        .. versionchanged:: 2.2.3
            Handle case where wrapped stream returns fewer bytes than requested.
        r)r��readallrhs r�exhaustzLimitedStream.exhaust�s��� � ��<�<�>�!�rc��t|�}|j|jz
}|dkr|j�yt	|j
d�rQ||kr	|j
j
|�}net|�}	|j
j
|�}|r<||d|n6	|j
jt||��}t|�}||d||s|j�y|xj|z
c_|S#ttf$r}|j|��Yd}~yd}~wwxYw#ttf$r}|j|��Yd}~yd}~wwxYw#ttf$r}|j|��Yd}~yd}~wwxYw)Nr�readinto)r�)
r�r�r�r�r�r�r��OSErrorr4r��	bytearrayr��min)r`�b�size�	remaining�out_size�e�temp_br�s        rr�zLimitedStream.readintosr���1�v���J�J����*�	���>�������4�<�<��,��y� ��+/�<�<�+@�+@��+C�H�#�9�-���#�|�|�4�4�V�<�H�
�#)�A�i�x�L�
��|�|�(�(��T�9�)=�>��
�4�y�H��A�i�x�L����� ���	�	�X��	����A ��,���&�&�Q�&�/����� ��,���&�&�Q�&�/������Z�(�
��"�"��"�+���
�sH�D�?D0�#%E�D-�D(�(D-�0E�?E�E�F	�-F�F	c��|jr|j�yt�}|js=|jd�}|s	t|�S|j	|�|js�=t|�S)Nri)r�r�r�r��extendrE)r`�outr�s   rr�zLimitedStream.readall8ss�����������k���#�#��9�9�Y�'�D����S�z��
�J�J�t���#�#��S�z�rc��|jS)zKReturn the current stream position.

        .. versionadded:: 0.9
        )r�rhs rr�zLimitedStream.tellKs��
�y�y�rc��yr�rrhs r�readablezLimitedStream.readableRs��r)F)rKr�r�r2rAr�rprqr�rsrg)r�zException | Nonerprqrr)r�r�rpr�)rpr2)rtrurvrwre�propertyr�r�r�r�r�r�r�r�rrrrFrF�sD���>$��'��'�
*�'�,
�.�`�&�rrF)rz t.Callable[..., WSGIApplication]rpr)FFFN)r)r
r*r�r+r�r,r�r-�t.Iterable[str] | Nonerp�str)r)r
rpztuple[str, int | None] | Nonerg)r)r
r-r�rpr�)r)r
rpr�)TN)r)r
rIr�rJr�rpr�)r)r
rpr�r�)r)r
rzr�r{r2rpro)!�
__future__rrG�typingrB�	functoolsrr�
exceptionsrr	�sansior
r'�sansio.utilsr�
TYPE_CHECKING�_typeshed.wsgirr
rr(r7r$r?rMrRrTr|ryr��	RawIOBaserFrrr�<module>r�s^��"�	���$�*�-�*�)��?�?�.�.�
8��#��,0�#2�
�#2��#2��#2��	#2�
*�#2�	�
#2�L�
��"��$GK��
��-C����8�"�%)�AF�
�AF��AF�#�AF��	AF�H)�1�1�jEI��
��$/��>A����.1�1�hT"�T"�nj�B�L�L�jr

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists