mirror of
https://github.com/cesanta/mongoose.git
synced 2026-11-27 20:48:29 +00:00
exporting correct SCRIPT_FILENAME for CGI
This commit is contained in:
1 parent
3e5d2bd3ac
commit
1811240587
2 files changed
+10
-7
No files matched your search
+8
-7
@@ -210,8 +210,9 @@ typedef int SOCKET;
|
|||||||
#if defined(DEBUG)
|
#if defined(DEBUG)
|
||||||
#define DEBUG_TRACE(x) do { \
|
#define DEBUG_TRACE(x) do { \
|
||||||
flockfile(stdout); \
|
flockfile(stdout); \
|
||||||
printf("*** [%lu] thread %p: %s: ", \
|
printf("*** %lu.%p.%s.%d: ", \
|
||||||
(unsigned long) time(NULL), (void *) pthread_self(), __func__); \
|
(unsigned long) time(NULL), (void *) pthread_self(), \
|
||||||
|
__func__, __LINE__); \
|
||||||
printf x; \
|
printf x; \
|
||||||
putchar('\n'); \
|
putchar('\n'); \
|
||||||
fflush(stdout); \
|
fflush(stdout); \
|
||||||
@@ -743,7 +744,6 @@ static void send_http_error(struct mg_connection *conn, int status,
|
|||||||
va_list ap;
|
va_list ap;
|
||||||
int len;
|
int len;
|
||||||
|
|
||||||
DEBUG_TRACE(("%d %s", status, reason));
|
|
||||||
conn->request_info.status_code = status;
|
conn->request_info.status_code = status;
|
||||||
|
|
||||||
if (call_user(conn, MG_HTTP_ERROR) == NULL) {
|
if (call_user(conn, MG_HTTP_ERROR) == NULL) {
|
||||||
@@ -757,9 +757,10 @@ static void send_http_error(struct mg_connection *conn, int status,
|
|||||||
buf[len++] = '\n';
|
buf[len++] = '\n';
|
||||||
|
|
||||||
va_start(ap, fmt);
|
va_start(ap, fmt);
|
||||||
mg_vsnprintf(conn, buf + len, sizeof(buf) - len, fmt, ap);
|
len += mg_vsnprintf(conn, buf + len, sizeof(buf) - len, fmt, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
}
|
}
|
||||||
|
DEBUG_TRACE(("[%s]", buf));
|
||||||
|
|
||||||
mg_printf(conn, "HTTP/1.1 %d %s\r\n"
|
mg_printf(conn, "HTTP/1.1 %d %s\r\n"
|
||||||
"Content-Type: text/plain\r\n"
|
"Content-Type: text/plain\r\n"
|
||||||
@@ -2777,7 +2778,7 @@ static void prepare_cgi_environment(struct mg_connection *conn,
|
|||||||
(slash - conn->request_info.uri) + 1, conn->request_info.uri,
|
(slash - conn->request_info.uri) + 1, conn->request_info.uri,
|
||||||
script_filename);
|
script_filename);
|
||||||
|
|
||||||
addenv(blk, "SCRIPT_FILENAME=%s", script_filename);
|
addenv(blk, "SCRIPT_FILENAME=%s", prog);
|
||||||
addenv(blk, "PATH_TRANSLATED=%s", prog);
|
addenv(blk, "PATH_TRANSLATED=%s", prog);
|
||||||
addenv(blk, "HTTPS=%s", conn->ssl == NULL ? "off" : "on");
|
addenv(blk, "HTTPS=%s", conn->ssl == NULL ? "off" : "on");
|
||||||
|
|
||||||
@@ -2898,8 +2899,8 @@ static void handle_cgi_request(struct mg_connection *conn, const char *prog) {
|
|||||||
buf, sizeof(buf), &data_len);
|
buf, sizeof(buf), &data_len);
|
||||||
if (headers_len <= 0) {
|
if (headers_len <= 0) {
|
||||||
send_http_error(conn, 500, http_500_error,
|
send_http_error(conn, 500, http_500_error,
|
||||||
"CGI program sent malformed HTTP headers: [%.*s]",
|
"CGI program sent malformed HTTP headers: [%.*s]",
|
||||||
data_len, buf);
|
data_len, buf);
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
pbuf = buf;
|
pbuf = buf;
|
||||||
|
|||||||
@@ -210,6 +210,8 @@ write_file($path, read_file($root . $dir_separator . 'env.cgi'));
|
|||||||
chmod 0755, $path;
|
chmod 0755, $path;
|
||||||
o("GET /$test_dir_uri/x/ HTTP/1.0\n\n", "Content-Type: text/html\r\n\r\n",
|
o("GET /$test_dir_uri/x/ HTTP/1.0\n\n", "Content-Type: text/html\r\n\r\n",
|
||||||
'index.cgi execution');
|
'index.cgi execution');
|
||||||
|
o("GET /$test_dir_uri/x/ HTTP/1.0\n\n",
|
||||||
|
"SCRIPT_FILENAME=test/test_dir/x/index.cgi", 'SCRIPT_FILENAME');
|
||||||
o("GET /ta/x/ HTTP/1.0\n\n", "SCRIPT_NAME=/ta/x/index.cgi",
|
o("GET /ta/x/ HTTP/1.0\n\n", "SCRIPT_NAME=/ta/x/index.cgi",
|
||||||
'Aliases SCRIPT_NAME');
|
'Aliases SCRIPT_NAME');
|
||||||
#o("GET /hello.txt HTTP/1.1\n\n GET /hello.txt HTTP/1.0\n\n",
|
#o("GET /hello.txt HTTP/1.1\n\n GET /hello.txt HTTP/1.0\n\n",
|
||||||
|
|||||||
Reference in new issue
Block a user