<s> from debtcollector import removals <EOL> from oslo_config import cfg <EOL> from oslo_middleware import base <EOL> OPTS = [ <EOL> cfg . BoolOpt ( '<STR_LIT>' , <EOL> default = False , <EOL> help = "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> ] <EOL> class HTTPProxyToWSGI ( base . ConfigurableMiddleware ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , application , * args , ** kwargs ) : <EOL> super ( HTTPProxyToWSGI , self ) . __init__ ( application , * args , ** kwargs ) <EOL> self . oslo_conf . register_opts ( OPTS , group = '<STR_LIT>' ) <EOL> @ staticmethod <EOL> def _parse_rfc7239_header ( header ) : <EOL> """<STR_LIT>""" <EOL> result = [ ] <EOL> for proxy in header . split ( "<STR_LIT:U+002C>" ) : <EOL> entry = { } <EOL> for d in proxy . split ( "<STR_LIT:;>" ) : <EOL> key , _ , value = d . partition ( "<STR_LIT:=>" ) <EOL> entry [ key . lower ( ) ] = value <EOL> result . append ( entry ) <EOL> return result <EOL> def process_request ( self , req ) : <EOL> if not self . _conf_get ( '<STR_LIT>' ) : <EOL> return <EOL> fwd_hdr = req . environ . get ( "<STR_LIT>" ) <EOL> if fwd_hdr : <EOL> proxies = self . _parse_rfc7239_header ( fwd_hdr ) <EOL> if proxies : <EOL> proxy = proxies [ <NUM_LIT:0> ] <EOL> forwarded_proto = proxy . get ( "<STR_LIT>" ) <EOL> if forwarded_proto : <EOL> req . environ [ '<STR_LIT>' ] = forwarded_proto <EOL> forwarded_host = proxy . get ( "<STR_LIT:host>" ) <EOL> if forwarded_host : <EOL> req . environ [ '<STR_LIT>' ] = forwarded_host <EOL> else : <EOL> forwarded_proto = req . environ . get ( "<STR_LIT>" ) <EOL> if forwarded_proto : <EOL> req . environ [ '<STR_LIT>' ] = forwarded_proto <EOL> forwarded_host = req . environ . get ( "<STR_LIT>" ) <EOL> if forwarded_host : <EOL> req . environ [ '<STR_LIT>' ] = forwarded_host <EOL> v = req . environ . get ( "<STR_LIT>" ) <EOL> if v : <EOL> req . environ [ '<STR_LIT>' ] = v + req . environ [ '<STR_LIT>' ] <EOL> @ removals . remove <EOL> class HTTPProxyToWSGIMiddleware ( HTTPProxyToWSGI ) : <EOL> """<STR_LIT>""" </s>
