small style and CGI message fix

This commit is contained in:
Hiltjo Posthuma 2014-08-14 17:07:33 +00:00 committed by FRIGN
parent bd9d7e3493
commit 159cdb3e0b

14
quark.c
View file

@ -57,9 +57,9 @@ enum {
static const char *resentry[] = { static const char *resentry[] = {
[HEADER] = "HTTP/1.1 %s\r\n" [HEADER] = "HTTP/1.1 %s\r\n"
"Connection: close\r\n" "Connection: close\r\n"
"Date: %s\r\n" "Date: %s\r\n"
"Server: quark-"VERSION"\r\n", "Server: quark-"VERSION"\r\n",
[CONTENTLEN] = "Content-Length: %lu\r\n", [CONTENTLEN] = "Content-Length: %lu\r\n",
[LOCATION] = "Location: %s%s\r\n", [LOCATION] = "Location: %s%s\r\n",
[CONTENTTYPE] = "Content-Type: %s\r\n", [CONTENTTYPE] = "Content-Type: %s\r\n",
@ -335,8 +335,8 @@ responsecgi(void) {
} }
pclose(cgi); pclose(cgi);
} else { } else {
logerrmsg("error\t%s requests %s, but cannot run cgi script %s\n", logerrmsg("error\t%s requests %s, but cannot run cgi script %s: %s\n",
host, cgi_script, reqbuf); host, reqbuf, cgi_script, strerror(errno));
if (putresentry(HEADER, HttpNotFound, tstamp(0)) if (putresentry(HEADER, HttpNotFound, tstamp(0))
|| putresentry(CONTENTTYPE, texthtml)) || putresentry(CONTENTTYPE, texthtml))
return; return;
@ -351,7 +351,7 @@ response(void) {
char *p; char *p;
struct stat st; struct stat st;
for (p = reqbuf; *p; p++) for (p = reqbuf; *p; p++) {
if (*p == '\\' || (*p == '/' && *(p + 1) == '.')) { if (*p == '\\' || (*p == '/' && *(p + 1) == '.')) {
/* don't serve bogus or hidden files */ /* don't serve bogus or hidden files */
if (putresentry(HEADER, HttpForbidden, tstamp(0)) if (putresentry(HEADER, HttpForbidden, tstamp(0))
@ -362,6 +362,8 @@ response(void) {
writetext("\r\n<html><body>"HttpForbidden"</body></html>\r\n"); writetext("\r\n<html><body>"HttpForbidden"</body></html>\r\n");
return; return;
} }
}
if (cgi_mode) { if (cgi_mode) {
responsecgi(); responsecgi();
} else { } else {