def cache_hostinfo(environ):
 hostinfo = {}
 if (environ.get('HTTPS') or (environ.get('wsgi.url_scheme') == 'https') or (environ.get('HTTP_X_FORWARDED_PROTO') == 'https')):
  hostinfo['protocol'] = 'https'
 else:
  hostinfo['protocol'] = 'http'
 if environ.get('HTTP_X_FORWARDED_HOST'):
  hostinfo['host'] = environ['HTTP_X_FORWARDED_HOST']
 elif environ.get('HTTP_HOST'):
  hostinfo['host'] = environ['HTTP_HOST']
 else:
  hostinfo['host'] = environ['SERVER_NAME']
  if (environ.get('wsgi.url_scheme') == 'https'):
   if (environ['SERVER_PORT'] != '443'):
    hostinfo['host'] += (':' + environ['SERVER_PORT'])
  elif (environ['SERVER_PORT'] != '80'):
   hostinfo['host'] += (':' + environ['SERVER_PORT'])
 environ['routes.cached_hostinfo'] = hostinfo
 return hostinfo

def cache_hostinfo ( environ ) : hostinfo = { } if ( environ . get ( 'HTTPS' ) or ( environ . get ( 'wsgi.url_scheme' ) == 'https' ) or ( environ . get ( 'HTTP_X_FORWARDED_PROTO' ) == 'https' ) ) : hostinfo [ 'protocol' ] = 'https' else : hostinfo [ 'protocol' ] = 'http' if environ . get ( 'HTTP_X_FORWARDED_HOST' ) : hostinfo [ 'host' ] = environ [ 'HTTP_X_FORWARDED_HOST' ] elif environ . get ( 'HTTP_HOST' ) : hostinfo [ 'host' ] = environ [ 'HTTP_HOST' ] else : hostinfo [ 'host' ] = environ [ 'SERVER_NAME' ] if ( environ . get ( 'wsgi.url_scheme' ) == 'https' ) : if ( environ [ 'SERVER_PORT' ] != '443' ) : hostinfo [ 'host' ] += ( ':' + environ [ 'SERVER_PORT' ] ) elif ( environ [ 'SERVER_PORT' ] != '80' ) : hostinfo [ 'host' ] += ( ':' + environ [ 'SERVER_PORT' ] ) environ [ 'routes.cached_hostinfo' ] = hostinfo return hostinfo
processes the host information and stores a copy this work was previously done but wasnt stored in environ .