Sindbad~EG File Manager
�
'ٜg� � � � d Z ddlmZ ddlZddlmZ ddlmZ ddlm Z ddl
mZ dd lmZ dd
l
mZ ej rddlmZ ddlmZ dd
lmZ G d� 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 �\ � e Zd ZdZ 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 ��ci c]! \ }}d|j d� � d� ||� ��# c}}| _ || _ || _ y c c}}w )Nc � � | j dd� | j dd� | j di � | j dd � | 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_defaultsY s? � ��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)�selfr r"