Sindbad~EG File Manager

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

�

'ٜg����dZddlmZddlZddlmZddlmZddlm	Z	ddl
mZdd	lmZdd
l
mZejrddlmZddlmZdd
lmZGd�d�Zy)zt
Basic HTTP Proxy
================

.. autoclass:: ProxyMiddleware

:copyright: 2007 Pallets
:license: BSD-3-Clause
�)�annotationsN)�client)�quote)�urlsplit�)�EnvironHeaders)�is_hop_by_hop_header)�get_input_stream)�
StartResponse)�WSGIApplication)�WSGIEnvironmentc�\�eZdZdZ		d									dd�Z								dd�Z						d	d�Zy)
�ProxyMiddlewarea�Proxy requests under a path to an external server, routing other
    requests to the app.

    This middleware can only proxy HTTP requests, as HTTP is the only
    protocol handled by the WSGI server. Other protocols, such as
    WebSocket requests, cannot be proxied at this layer. This should
    only be used for development, in production a real proxy server
    should be used.

    The middleware takes a dict mapping a path prefix to a dict
    describing the host to be proxied to::

        app = ProxyMiddleware(app, {
            "/static/": {
                "target": "http://127.0.0.1:5001/",
            }
        })

    Each host has the following options:

    ``target``:
        The target URL to dispatch to. This is required.
    ``remove_prefix``:
        Whether to remove the prefix from the URL before dispatching it
        to the target. The default is ``False``.
    ``host``:
        ``"<auto>"`` (default):
            The host header is automatically rewritten to the URL of the
            target.
        ``None``:
            The host header is unmodified from the client request.
        Any other value:
            The host header is overwritten with the value.
    ``headers``:
        A dictionary of headers to be sent with the request to the
        target. The default is ``{}``.
    ``ssl_context``:
        A :class:`ssl.SSLContext` defining how to verify requests if the
        target is HTTPS. The default is ``None``.

    In the example above, everything under ``"/static/"`` is proxied to
    the server on port 5001. The host header is rewritten to the target,
    and the ``"/static/"`` prefix is removed from the URLs.

    :param app: The WSGI application to wrap.
    :param targets: Proxy target configurations. See description above.
    :param chunk_size: Size of chunks to read from input stream and
        write to target.
    :param timeout: Seconds before an operation to a target fails.

    .. versionadded:: 0.14
    c���dd�}||_|j�D��cic]!\}}d|jd��d�||���#c}}|_||_||_ycc}}w)Nc��|jdd�|jdd�|jdi�|jdd�|S)N�
remove_prefixF�host�<auto>�headers�ssl_context)�
setdefault)�optss �I/usr/local/lib/python3.12/site-packages/werkzeug/middleware/http_proxy.py�
_set_defaultsz/ProxyMiddleware.__init__.<locals>._set_defaultsYs?���O�O�O�U�3��O�O�F�H�-��O�O�I�r�*��O�O�M�4�0��K��/)r�dict[str, t.Any]�returnr)�app�items�strip�targets�
chunk_size�timeout)�selfrr"r#r$r�k�vs        r�__init__zProxyMiddleware.__init__Rse��	����>E�m�m�o�
�>M�d�a��a������~�Q���q�!1�1�o�
���%�������	
s�&Ac��������t�d���jjd�jd��						d������fd�}|S)N�target�idna�asciic
����tt|�j��}|D��cgc]&\}}t|�s|j	�dvr||f��(c}}|dd|jd��ddk(r|jd�f�n2�d�|jd|df�n|jd�df�|j
�dj���}�dr=|t��djd	�}�jjd	��d	|��}|jd
�}d}|dvr|jd
|f�n|�|jd�d}	�jdk(r1tj��jxsd�j ��}n]�jdk(r5tj"��jxsd�j �d��}nt%d�j�d���|j'�t)|d��}	|d}
|
r|	�d|
��}	|j+|d|	d��|D],\}}|j	�dk(rd }|j-||��.|j/�t1|�}	|j3�j4�}|sn4|r |j7d!t|�|fz�n|j7|��R|j9��|�j@�d$�jB���jE�D��cgc]"\}}t|�s|jG�|f��$c}}�d&��fd%�}|�Scc}}w#t:$rd"d#lm}
|
�||�cYSwxYwcc}}w)'N)zcontent-lengthr)�
Connection�closerr�Host�	HTTP_HOSTrrr�CONTENT_LENGTHF)�NzContent-Length)zTransfer-Encoding�chunkedT�http�P)r$�httpsi�r)r$�contextz-Target scheme must be 'http' or 'https', got �.z!$&'()*+,/:;=@%)�safe�QUERY_STRING�?�REQUEST_METHOD)�	skip_host�
connectionr/s%x
%s
r)�
BadGateway� c3�t�K�		�j�j�}|sy|���$#t$rYywxYw�w)N)�readr#�OSError)�data�respr%s ��rrCz;ProxyMiddleware.proxy_to.<locals>.application.<locals>.read�sF�������#�y�y����9�� ���J���#����s�8�)�8�	5�8�5�8)rzt.Iterator[bytes])$�listrr r	�lower�append�extend�len�lstrip�path�rstrip�get�schemer�HTTPConnection�portr$�HTTPSConnection�RuntimeError�connectr�
putrequest�	putheader�
endheadersr
rCr#�send�getresponserD�
exceptionsr@�status�reason�
getheaders�title)�environ�start_responserr&r'�remote_path�content_lengthr4�con�
remote_url�querystring�streamrEr@rCrFrrrM�prefixr%r*s               @������r�applicationz-ProxyMiddleware.proxy_to.<locals>.applicationns����>�'�2�8�8�:�;�G�$��#�D�A�q�+�A�.��G�G�I�%?�?��A��#��G�A�J�
�N�N�2�3��F�|�x�'������~�.��f��%�������(<�=�>������V��5�6��N�N�4�	�?�0�0�2�3��K��O�$�)�#�f�+�-�8�?�?��D��!'���!3�!3�C�!8� 9��;�-�H��$�[�[�)9�:�N��G��Z�/���� 0�.�A�B��+����?�@���5
=��=�=�F�*� �/�/��f�k�k�/�R�����C��]�]�g�-� �0�0�����*�s� $��� $�]� 3�	�C�'��"�M�M�,�A�/���
���
�#�;�5F�G�
�%�n�5���$.�<�q��
�!>�J����w�'7�8�*�PT��U�#�D�A�q��w�w�y�L�0�#���M�M�!�Q�'�	$���� �)�'�2���!�;�;�t���7�D��������C��I�t�3D�!D�E����������(��
��;�;�-�q����
�.�!%��� 1�� 1���1�/��2��W�W�Y��N� 1��
�

��6�M��W��b�
=�3�#�z�|�G�^�<�<�
=��s�+M�"FM"�'N�"N�N�r`r
rarrzt.Iterable[bytes])r�hostname�encode�decode)r%rrMrhrirr*s```` @@r�proxy_tozProxyMiddleware.proxy_togsb����$�x�.�)�����%�%�f�-�4�4�W�=��o	�$�o	�6C�o	�
�o	�o	�b�rc���|d}|j}|jj�D]+\}}|j|�s�|j	|||�}n|||�S)N�	PATH_INFO)rr"r �
startswithrn)r%r`rarMrrhrs       r�__call__zProxyMiddleware.__call__�sb���{�#���h�h�� �L�L�.�.�0�L�F�D����v�&��m�m�D�$��7���1�
�7�N�+�+rN)i@�
)
rrr"z t.Mapping[str, dict[str, t.Any]]r#�intr$rtr�None)rrrM�strrhrvrrrj)�__name__�
__module__�__qualname__�__doc__r(rnrr�rrrrs���3�r"���
��2���	�
��
�
�*x�$�x�,/�x�9<�x�	�x�t,�&�,�8E�,�	�,rr)rz�
__future__r�typing�tr5r�urllib.parserr�datastructuresrr	�wsgir
�
TYPE_CHECKING�_typeshed.wsgirrr
rr{rr�<module>r�s@���#����!�+�'�#��?�?�,�.�.�P,�P,r

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