def _request_uri(environ):
 url = (environ['wsgi.url_scheme'] + '://')
 if environ.get('HTTP_HOST'):
  url += environ['HTTP_HOST']
 else:
  url += ((environ['SERVER_NAME'] + ':') + environ['SERVER_PORT'])
 if (url.endswith(':80') and (environ['wsgi.url_scheme'] == 'http')):
  url = url[:(-3)]
 elif (url.endswith(':443') and (environ['wsgi.url_scheme'] == 'https')):
  url = url[:(-4)]
 if PY3:
  script_name = bytes_(environ.get('SCRIPT_NAME', '/'), 'latin-1')
  path_info = bytes_(environ.get('PATH_INFO', ''), 'latin-1')
 else:
  script_name = environ.get('SCRIPT_NAME', '/')
  path_info = environ.get('PATH_INFO', '')
 url += url_quote(script_name)
 qpath_info = url_quote(path_info)
 if (not ('SCRIPT_NAME' in environ)):
  url += qpath_info[1:]
 else:
  url += qpath_info
 return url

def _request_uri ( environ ) : url = ( environ [ 'wsgi.url_scheme' ] + '://' ) if environ . get ( 'HTTP_HOST' ) : url += environ [ 'HTTP_HOST' ] else : url += ( ( environ [ 'SERVER_NAME' ] + ':' ) + environ [ 'SERVER_PORT' ] ) if ( url . endswith ( ':80' ) and ( environ [ 'wsgi.url_scheme' ] == 'http' ) ) : url = url [ : ( - 3 ) ] elif ( url . endswith ( ':443' ) and ( environ [ 'wsgi.url_scheme' ] == 'https' ) ) : url = url [ : ( - 4 ) ] if PY3 : script_name = bytes_ ( environ . get ( 'SCRIPT_NAME' , '/' ) , 'latin-1' ) path_info = bytes_ ( environ . get ( 'PATH_INFO' , '' ) , 'latin-1' ) else : script_name = environ . get ( 'SCRIPT_NAME' , '/' ) path_info = environ . get ( 'PATH_INFO' , '' ) url += url_quote ( script_name ) qpath_info = url_quote ( path_info ) if ( not ( 'SCRIPT_NAME' in environ ) ) : url += qpath_info [ 1 : ] else : url += qpath_info return url
like wsgiref .