File manager - Edit - /opt/imh-python/lib/python2.7/site-packages/werkzeug/contrib/fixers.pyc
Back
� ��Qc @ s� d Z y d d l m Z Wn! e k r= d d l m Z n Xd d l m Z m Z m Z d d l m Z d d l m Z m Z d e f d � � YZ e Z d e f d � � YZ d e f d � � YZ d e f d � � YZ d e f d � � YZ d S( sl werkzeug.contrib.fixers ~~~~~~~~~~~~~~~~~~~~~~~ .. versionadded:: 0.5 This module includes various helpers that fix bugs in web servers. They may be necessary for some versions of a buggy web server but not others. We try to stay updated with the status of the bugs as good as possible but you have to make sure whether they fix the problem you encounter. If you notice bugs in webservers not fixed in this module consider contributing a patch. :copyright: Copyright 2009 by the Werkzeug Team, see AUTHORS for more details. :license: BSD, see LICENSE for more details. i����( t unquote( t parse_options_headert parse_cache_control_headert parse_set_header( t UserAgent( t Headerst ResponseCacheControlt CGIRootFixc B s# e Z d Z d d � Z d � Z RS( s� Wrap the application in this middleware if you are using FastCGI or CGI and you have problems with your app root being set to the cgi script's path instead of the path users are going to visit .. versionchanged:: 0.9 Added `app_root` parameter and renamed from `LighttpdCGIRootFix`. :param app: the WSGI application :param app_root: Defaulting to ``'/'``, you can set this to something else if your app is mounted somewhere else. t /c C s | | _ | | _ d S( N( t appt app_root( t selfR R ( ( sF /opt/imh-python/lib/python2.7/site-packages/werkzeug/contrib/fixers.pyt __init__* s c C sk d | k s | d d k rE | j d d � | j d d � | d <n | j j d � | d <| j | | � S( Nt SERVER_SOFTWAREs lighttpd/1.4.28t SCRIPT_NAMEt t PATH_INFOR ( t getR t stripR ( R t environt start_response( ( sF /opt/imh-python/lib/python2.7/site-packages/werkzeug/contrib/fixers.pyt __call__. s ( t __name__t __module__t __doc__R R ( ( ( sF /opt/imh-python/lib/python2.7/site-packages/werkzeug/contrib/fixers.pyR s t PathInfoFromRequestUriFixc B s e Z d Z d � Z d � Z RS( s On windows environment variables are limited to the system charset which makes it impossible to store the `PATH_INFO` variable in the environment without loss of information on some systems. This is for example a problem for CGI scripts on a Windows Apache. This fixer works by recreating the `PATH_INFO` from `REQUEST_URI`, `REQUEST_URL`, or `UNENCODED_URL` (whatever is available). Thus the fix can only be applied if the webserver supports either of these variables. :param app: the WSGI application c C s | | _ d S( N( R ( R R ( ( sF /opt/imh-python/lib/python2.7/site-packages/werkzeug/contrib/fixers.pyR N s c C s� x d D]w } | | k r q n t | | � } t | j d d � � } | j | � r | t | � j d d � d | d <Pq q W| j | | � S( Nt REQUEST_URLt REQUEST_URIt UNENCODED_URLR R t ?i i R ( R R R ( R R t startswitht lent splitR ( R R R t keyt request_urit script_name( ( sF /opt/imh-python/lib/python2.7/site-packages/werkzeug/contrib/fixers.pyR Q s ( R R R R R ( ( ( sF /opt/imh-python/lib/python2.7/site-packages/werkzeug/contrib/fixers.pyR ? s t ProxyFixc B s, e Z d Z d d � Z d � Z d � Z RS( s� This middleware can be applied to add HTTP proxy support to an application that was not designed with HTTP proxies in mind. It sets `REMOTE_ADDR`, `HTTP_HOST` from `X-Forwarded` headers. If you have more than one proxy server in front of your app, set `num_proxies` accordingly. Do not use this middleware in non-proxy setups for security reasons. The original values of `REMOTE_ADDR` and `HTTP_HOST` are stored in the WSGI environment as `werkzeug.proxy_fix.orig_remote_addr` and `werkzeug.proxy_fix.orig_http_host`. :param app: the WSGI application :param num_proxies: the number of proxy servers in front of the app. i c C s | | _ | | _ d S( N( R t num_proxies( R R R% ( ( sF /opt/imh-python/lib/python2.7/site-packages/werkzeug/contrib/fixers.pyR p s c C s( t | � | j k r$ | d | j Sd S( s� Selects the new remote addr from the given list of ips in X-Forwarded-For. By default it picks the one that the `num_proxies` proxy server provides. Before 0.9 it would always pick the first. .. versionadded:: 0.8 i����N( R R% ( R t forwarded_for( ( sF /opt/imh-python/lib/python2.7/site-packages/werkzeug/contrib/fixers.pyt get_remote_addrt s c C s | j } | d d � } | d d � j d � } | d d � } | j i | d � d 6| d � d 6| d � d 6� g g | D] } | j � ^ q} D] } | r� | ^ q� } | j | � } | d k r� | | d <n | r� | | d <n | r� | | d <n | j | | � S( Nt HTTP_X_FORWARDED_PROTOR t HTTP_X_FORWARDED_FORt ,t HTTP_X_FORWARDED_HOSTs wsgi.url_schemes'