def build_wsgi_request(request):
  wsgi_request = {
    "SERVER_PORT":     request.get("server_port"),
    "SERVER_NAME":     request.get("server_name"),
    "REMOTE_ADDR":     request.get("remote_addr"),
    "RAW_URI":         request.get("uri"),
    "PATH_INFO":       request.get("uri"),
    "QUERY_STRING":    request.get("query_string"),
    "wsgi.url_scheme": request.get("scheme"),
    "REQUEST_METHOD":  request.get("method", "GET").upper(),
    "CONTENT_TYPE":    request.get("content_type"),
    "CONTENT_LENGTH":  request.get("content_length"),
    "wsgi.input":      request.get("body")}
  for key, value in request.get("headers", {}).iteritems():
    wsgi_request["HTTP_%s" % key.upper()] = value

  for key, value in request.iteritems():
    if key.upper() not in wsgi_request:
      wsgi_request[key] = value

  return wsgi_request

# Convert a Pump response to a WSGI response.
dataset/ETHPy150Open adeel/pump/pump/util/wsgi.py/build_wsgi_request/original