80 const char *path_cstr = hreq->path;
81 std::string path(path_cstr);
82 const char *program_cstr = it->program.c_str();
83 std::string script_name(path, 0, it->path.length());
84 std::string rest(path, it->path.length());
85 std::string query_string;
86 std::string path_info;
87 size_t qpos = rest.find(
'?');
88 if (qpos == std::string::npos)
92 query_string.assign(rest, qpos + 1, std::string::npos);
93 path_info.assign(rest, 0, qpos);
95 setenv(
"REQUEST_METHOD", hreq->method, 1);
96 setenv(
"REQUEST_URI", path_cstr, 1);
97 setenv(
"SCRIPT_NAME", script_name.c_str(), 1);
98 setenv(
"PATH_INFO", path_info.c_str(), 1);
99 setenv(
"QUERY_STRING", query_string.c_str(), 1);
101 v = z_HTTP_header_lookup(hreq->headers,
"Cookie");
103 setenv(
"HTTP_COOKIE", v, 1);
104 v = z_HTTP_header_lookup(hreq->headers,
"User-Agent");
106 setenv(
"HTTP_USER_AGENT", v, 1);
107 v = z_HTTP_header_lookup(hreq->headers,
"Accept");
109 setenv(
"HTTP_ACCEPT", v, 1);
110 v = z_HTTP_header_lookup(hreq->headers,
"Accept-Encoding");
112 setenv(
"HTTP_ACCEPT_ENCODING", v, 1);
114 setenv(
"GATEWAY_INTERFACE",
"CGI/1.1", 1);
116 v = z_HTTP_header_lookup(hreq->headers,
"Content-Type");
120 sprintf(tmp,
"%d", hreq->content_len);
121 setenv(
"CONTENT_LENGTH", tmp, 1);
122 setenv(
"CONTENT_TYPE", v, 1);
125 std::map<std::string,std::string>::const_iterator it_e;
128 setenv(it_e->first.c_str(), it_e->second.c_str(), 1);
132 char *program = xstrdup(program_cstr);
133 char *cp = strrchr(program,
'/');
141 int r = execl(cp, cp, (
char *) 0);