if(getenv("HTTP_VERSION"))
putenv(sprintf2("SERVER_PROTOCOL=%s", getenv("HTTP_VERSION")));
putenv(sprintf2("REQUEST_METHOD=%s", method));
- if(*rest)
- putenv(sprintf2("PATH_INFO=/%s", rest));
- else
- putenv("PATH_INFO=");
+ putenv(sprintf2("PATH_INFO=%s", rest));
name = url;
/* XXX: This is an ugly hack (I think), but though I can think
* of several alternatives, none seem to be better. */
- if(*rest && (strlen(url) > strlen(rest)) &&
- !strcmp(rest, url + strlen(url) - strlen(rest)) &&
- (url[strlen(url) - strlen(rest) - 1] == '/')) {
- name = sprintf2("%.*s", (int)(strlen(url) - strlen(rest) - 1), url);
+ if(*rest && (strlen(url) >= strlen(rest)) &&
+ !strcmp(rest, url + strlen(url) - strlen(rest))) {
+ name = sprintf2("%.*s", (int)(strlen(url) - strlen(rest)), url);
}
putenv(sprintf2("SCRIPT_NAME=%s", name));
putenv(sprintf2("QUERY_STRING=%s", qp?qp:""));
bufaddenv(dst, "SERVER_PROTOCOL", "%s", req->ver);
bufaddenv(dst, "REQUEST_METHOD", "%s", req->method);
bufaddenv(dst, "REQUEST_URI", "%s", req->url);
- if(*req->rest)
- bufaddenv(dst, "PATH_INFO", "/%s", req->rest);
- else
- bufaddenv(dst, "PATH_INFO", "");
+ bufaddenv(dst, "PATH_INFO", req->rest);
url = sstrdup(req->url);
if((qp = strchr(url, '?')) != NULL)
*(qp++) = 0;
/* XXX: This is an ugly hack (I think), but though I can think of
* several alternatives, none seem to be better. */
- if(*req->rest && (strlen(url) > strlen(req->rest)) &&
- !strcmp(req->rest, url + strlen(url) - strlen(req->rest)) &&
- (url[strlen(url) - strlen(req->rest) - 1] == '/')) {
- bufaddenv(dst, "SCRIPT_NAME", "%.*s", (int)(strlen(url) - strlen(req->rest) - 1), url);
+ if(*req->rest && (strlen(url) >= strlen(req->rest)) &&
+ !strcmp(req->rest, url + strlen(url) - strlen(req->rest))) {
+ bufaddenv(dst, "SCRIPT_NAME", "%.*s", (int)(strlen(url) - strlen(req->rest)), url);
} else {
bufaddenv(dst, "SCRIPT_NAME", "%s", url);
}