def create_environ(path='/', query_string='', protocol='HTTP/1.1', scheme='http', host=DEFAULT_HOST, port=None, headers=None, app='', body='', method='GET', wsgierrors=None, file_wrapper=None):
 if (query_string and query_string.startswith('?')):
  raise ValueError("query_string should not start with '?'")
 body = io.BytesIO((body.encode('utf-8') if isinstance(body, six.text_type) else body))
 path = uri.decode(path)
 if six.PY3:
  path = path.encode('utf-8').decode('iso-8859-1')
 if (six.PY2 and isinstance(path, six.text_type)):
  path = path.encode('utf-8')
 scheme = scheme.lower()
 if (port is None):
  port = ('80' if (scheme == 'http') else '443')
 else:
  port = str(port)
 env = {'SERVER_PROTOCOL': protocol, 'SERVER_SOFTWARE': 'gunicorn/0.17.0', 'SCRIPT_NAME': app, 'REQUEST_METHOD': method, 'PATH_INFO': path, 'QUERY_STRING': query_string, 'HTTP_USER_AGENT': 'curl/7.24.0 (x86_64-apple-darwin12.0)', 'REMOTE_PORT': '65133', 'RAW_URI': '/', 'REMOTE_ADDR': '127.0.0.1', 'SERVER_NAME': host, 'SERVER_PORT': port, 'wsgi.version': (1, 0), 'wsgi.url_scheme': scheme, 'wsgi.input': body, 'wsgi.errors': (wsgierrors or sys.stderr), 'wsgi.multithread': False, 'wsgi.multiprocess': True, 'wsgi.run_once': False}
 if (file_wrapper is not None):
  env['wsgi.file_wrapper'] = file_wrapper
 if (protocol != 'HTTP/1.0'):
  host_header = host
  if (scheme == 'https'):
   if (port != '443'):
    host_header += (':' + port)
  elif (port != '80'):
   host_header += (':' + port)
  env['HTTP_HOST'] = host_header
 content_length = body.seek(0, 2)
 body.seek(0)
 if (content_length != 0):
  env['CONTENT_LENGTH'] = str(content_length)
 if (headers is not None):
  _add_headers_to_environ(env, headers)
 return env

def create_environ ( path = '/' , query_string = '' , protocol = 'HTTP/1.1' , scheme = 'http' , host = DEFAULT_HOST , port = None , headers = None , app = '' , body = '' , method = 'GET' , wsgierrors = None , file_wrapper = None ) : if ( query_string and query_string . startswith ( '?' ) ) : raise ValueError ( "query_string should not start with '?'" ) body = io . BytesIO ( ( body . encode ( 'utf-8' ) if isinstance ( body , six . text_type ) else body ) ) path = uri . decode ( path ) if six . PY3 : path = path . encode ( 'utf-8' ) . decode ( 'iso-8859-1' ) if ( six . PY2 and isinstance ( path , six . text_type ) ) : path = path . encode ( 'utf-8' ) scheme = scheme . lower ( ) if ( port is None ) : port = ( '80' if ( scheme == 'http' ) else '443' ) else : port = str ( port ) env = { 'SERVER_PROTOCOL' : protocol , 'SERVER_SOFTWARE' : 'gunicorn/0.17.0' , 'SCRIPT_NAME' : app , 'REQUEST_METHOD' : method , 'PATH_INFO' : path , 'QUERY_STRING' : query_string , 'HTTP_USER_AGENT' : 'curl/7.24.0 (x86_64-apple-darwin12.0)' , 'REMOTE_PORT' : '65133' , 'RAW_URI' : '/' , 'REMOTE_ADDR' : '127.0.0.1' , 'SERVER_NAME' : host , 'SERVER_PORT' : port , 'wsgi.version' : ( 1 , 0 ) , 'wsgi.url_scheme' : scheme , 'wsgi.input' : body , 'wsgi.errors' : ( wsgierrors or sys . stderr ) , 'wsgi.multithread' : False , 'wsgi.multiprocess' : True , 'wsgi.run_once' : False } if ( file_wrapper is not None ) : env [ 'wsgi.file_wrapper' ] = file_wrapper if ( protocol != 'HTTP/1.0' ) : host_header = host if ( scheme == 'https' ) : if ( port != '443' ) : host_header += ( ':' + port ) elif ( port != '80' ) : host_header += ( ':' + port ) env [ 'HTTP_HOST' ] = host_header content_length = body . seek ( 0 , 2 ) body . seek ( 0 ) if ( content_length != 0 ) : env [ 'CONTENT_LENGTH' ] = str ( content_length ) if ( headers is not None ) : _add_headers_to_environ ( env , headers ) return env
create a new wsgi environ dict based on the values passed .