#NEWLINE# def environ_from_url( path ) : #NEWLINE# #INDENT# if SCHEME_RE . search ( path ) : #NEWLINE# #INDENT# ( scheme , netloc , path , qs , fragment ) = urlparse . urlsplit ( path ) #NEWLINE# if fragment : #NEWLINE# #INDENT# raise TypeError ( ( 'Path cannot contain a fragment (%r)' % fragment ) ) #NEWLINE# #UNINDENT# if qs : #NEWLINE# #INDENT# path += ( '?' + qs ) #NEWLINE# #UNINDENT# if ( ':' not in netloc ) : #NEWLINE# #INDENT# if ( scheme == 'http' ) : #NEWLINE# #INDENT# netloc += ':80' #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( scheme == 'https' ) : #NEWLINE# #INDENT# netloc += ':443' #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# raise TypeError ( ( 'Unknown scheme: %r' % scheme ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# scheme = 'http' #NEWLINE# netloc = 'localhost:80' #NEWLINE# #UNINDENT# if ( path and ( '?' in path ) ) : #NEWLINE# #INDENT# ( path_info , query_string ) = path . split ( '?' , 1 ) #NEWLINE# path_info = url_unquote ( path_info ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# path_info = url_unquote ( path ) #NEWLINE# query_string = '' #NEWLINE# #UNINDENT# env = { #NEWLINE# #INDENT# 'REQUEST_METHOD' : 'GET' , #NEWLINE# 'SCRIPT_NAME' : '' , #NEWLINE# 'PATH_INFO' : ( path_info or '' ) , #NEWLINE# 'QUERY_STRING' : query_string , #NEWLINE# 'SERVER_NAME' : netloc . split ( ':' ) [ 0 ] , #NEWLINE# 'SERVER_PORT' : netloc . split ( ':' ) [ 1 ] , #NEWLINE# 'HTTP_HOST' : netloc , #NEWLINE# 'SERVER_PROTOCOL' : 'HTTP/1.0' , #NEWLINE# 'wsgi.version' : ( 1 , 0 ) , #NEWLINE# 'wsgi.url_scheme' : scheme , #NEWLINE# 'wsgi.input' : io . BytesIO ( ) , #NEWLINE# 'wsgi.errors' : sys . stderr , #NEWLINE# 'wsgi.multithread' : False , #NEWLINE# 'wsgi.multiprocess' : False , #NEWLINE# 'wsgi.run_once' : False , #NEWLINE# #UNINDENT# } #NEWLINE# return env