env["SCRIPT_NAME"] = name
env["PATH_INFO"] = pi
if "Host" in req: env["SERVER_NAME"] = req["Host"]
+ if "X-Ash-Server-Address" in req: env["SERVER_ADDR"] = req["X-Ash-Server-Address"]
if "X-Ash-Server-Port" in req: env["SERVER_PORT"] = req["X-Ash-Server-Port"]
if "X-Ash-Protocol" in req and req["X-Ash-Protocol"] == "https": env["HTTPS"] = "on"
if "X-Ash-Address" in req: env["REMOTE_ADDR"] = req["X-Ash-Address"]
+ if "X-Ash-Port" in req: env["REMOTE_PORT"] = req["X-Ash-Port"]
if "Content-Type" in req:
env["CONTENT_TYPE"] = req["Content-Type"]
# The CGI specification does not strictly require this, but
name = ""
env["SCRIPT_NAME"] = name
env["PATH_INFO"] = pi
- for src, tgt in [("HTTP_HOST", "SERVER_NAME"), ("HTTP_X_ASH_SERVER_PORT", "SERVER_PORT"),
- ("HTTP_X_ASH_ADDRESS", "REMOTE_ADDR"), ("HTTP_CONTENT_TYPE", "CONTENT_TYPE"),
- ("HTTP_CONTENT_LENGTH", "CONTENT_LENGTH"), ("HTTP_X_ASH_PROTOCOL", "wsgi.url_scheme")]:
+ for src, tgt in [("HTTP_HOST", "SERVER_NAME"), ("HTTP_X_ASH_PROTOCOL", "wsgi.url_scheme"),
+ ("HTTP_X_ASH_SERVER_ADDRESS", "SERVER_ADDR"), ("HTTP_X_ASH_SERVER_PORT", "SERVER_PORT"),
+ ("HTTP_X_ASH_ADDRESS", "REMOTE_ADDR"), ("HTTP_X_ASH_PORT", "REMOTE_PORT"),
+ ("HTTP_CONTENT_TYPE", "CONTENT_TYPE"), ("HTTP_CONTENT_LENGTH", "CONTENT_LENGTH")]:
if src in env: env[tgt] = env[src]
for key in ["HTTP_CONTENT_TYPE", "HTTP_CONTENT_LENGTH"]:
# The CGI specification does not strictly require this, but
putenv(sprintf2("QUERY_STRING=%s", qp?qp:""));
if(getenv("REQ_HOST"))
putenv(sprintf2("SERVER_NAME=%s", getenv("REQ_HOST")));
+ if(getenv("REQ_X_ASH_SERVER_ADDRESS"))
+ putenv(sprintf2("SERVER_ADDR=%s", getenv("REQ_X_ASH_SERVER_ADDRESS")));
if(getenv("REQ_X_ASH_SERVER_PORT"))
putenv(sprintf2("SERVER_PORT=%s", getenv("REQ_X_ASH_SERVER_PORT")));
if(getenv("REQ_X_ASH_PROTOCOL") && !strcmp(getenv("REQ_X_ASH_PROTOCOL"), "https"))
putenv("HTTPS=on");
if(getenv("REQ_X_ASH_ADDRESS"))
putenv(sprintf2("REMOTE_ADDR=%s", getenv("REQ_X_ASH_ADDRESS")));
+ if(getenv("REQ_X_ASH_PORT"))
+ putenv(sprintf2("REMOTE_PORT=%s", getenv("REQ_X_ASH_PORT")));
if(getenv("REQ_X_ASH_REMOTE_USER"))
putenv(sprintf2("REMOTE_USER=%s", getenv("REQ_X_ASH_REMOTE_USER")));
if(getenv("REQ_CONTENT_TYPE"))
free(url);
if((h = getheader(req, "Host")) != NULL)
bufaddenv(dst, "SERVER_NAME", "%s", h);
+ if((h = getheader(req, "X-Ash-Server-Address")) != NULL)
+ bufaddenv(dst, "SERVER_ADDR", "%s", h);
if((h = getheader(req, "X-Ash-Server-Port")) != NULL)
bufaddenv(dst, "SERVER_PORT", "%s", h);
if((h = getheader(req, "X-Ash-Remote-User")) != NULL)
bufaddenv(dst, "HTTPS", "on");
if((h = getheader(req, "X-Ash-Address")) != NULL)
bufaddenv(dst, "REMOTE_ADDR", "%s", h);
+ if((h = getheader(req, "X-Ash-Port")) != NULL)
+ bufaddenv(dst, "REMOTE_PORT", "%s", h);
if((h = getheader(req, "Content-Type")) != NULL)
bufaddenv(dst, "CONTENT_TYPE", "%s", h);
if((h = getheader(req, "Content-Length")) != NULL)
free(url);
if((h = getheader(req, "Host")) != NULL)
bufaddenv(dst, "SERVER_NAME", "%s", h);
+ if((h = getheader(req, "X-Ash-Server-Address")) != NULL)
+ bufaddenv(dst, "SERVER_ADDR", "%s", h);
if((h = getheader(req, "X-Ash-Server-Port")) != NULL)
bufaddenv(dst, "SERVER_PORT", "%s", h);
if((h = getheader(req, "X-Ash-Remote-User")) != NULL)
bufaddenv(dst, "HTTPS", "on");
if((h = getheader(req, "X-Ash-Address")) != NULL)
bufaddenv(dst, "REMOTE_ADDR", "%s", h);
+ if((h = getheader(req, "X-Ash-Port")) != NULL)
+ bufaddenv(dst, "REMOTE_PORT", "%s", h);
if((h = getheader(req, "Content-Type")) != NULL)
bufaddenv(dst, "CONTENT_TYPE", "%s", h);
if((h = getheader(req, "Content-Length")) != NULL)