mirror of https://github.com/nealey/eris.git
commit
1a707fea54
11
cgi.c
11
cgi.c
|
@ -30,6 +30,17 @@ cgi_child(const char *relpath)
|
||||||
env("CONTENT_TYPE", content_type);
|
env("CONTENT_TYPE", content_type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Change to CGI's directory */
|
||||||
|
{
|
||||||
|
char *delim = strrchr(relpath, '/');
|
||||||
|
|
||||||
|
if (delim) {
|
||||||
|
*delim = '\0';
|
||||||
|
chdir(relpath);
|
||||||
|
relpath = delim + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
execl(relpath, relpath, NULL);
|
execl(relpath, relpath, NULL);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
9
test.sh
9
test.sh
|
@ -43,6 +43,7 @@ cat <<'EOD' > default/a.cgi
|
||||||
echo 'Content-type: text/plain'
|
echo 'Content-type: text/plain'
|
||||||
echo
|
echo
|
||||||
set | sort
|
set | sort
|
||||||
|
ls *.cgi
|
||||||
EOD
|
EOD
|
||||||
chmod +x default/a.cgi
|
chmod +x default/a.cgi
|
||||||
|
|
||||||
|
@ -88,10 +89,10 @@ echo "IDX: $HTTPD_IDX "
|
||||||
H "Basic tests"
|
H "Basic tests"
|
||||||
|
|
||||||
title "GET /index.html"
|
title "GET /index.html"
|
||||||
printf 'GET /index.html HTTP/1.0\r\n\r\n' | $HTTPD 2>/dev/null | d | grep -q 'HTTP/1.0 200 OK#%Server: [a-z]*/[0-9a-z.]*#%Connection: close#%Content-Type: text/html; charset=UTF-8#%Content-Length: 6#%Last-Modified: ..., .. ... 20.. ..:..:.. GMT#%#%james%' && pass || fail
|
printf 'GET /index.html HTTP/1.0\r\n\r\n' | $HTTPD 2>/dev/null | d | grep -q 'HTTP/1.0 200 OK#%Server: eris/[0-9.a-z]*#%Connection: close#%Content-Type: text/html; charset=UTF-8#%Content-Length: 6#%Last-Modified: ..., .. ... 20.. ..:..:.. GMT#%#%james%' && pass || fail
|
||||||
|
|
||||||
title "GET /"
|
title "GET /"
|
||||||
printf 'GET / HTTP/1.0\r\n\r\n' | $HTTPD 2>/dev/null | d | grep -q 'HTTP/1.0 200 OK#%Server: [a-z]*/[0-9a-z.]*#%Connection: close#%Content-Type: text/html; charset=UTF-8#%Content-Length: 6#%Last-Modified: ..., .. ... 20.. ..:..:.. GMT#%#%james%' && pass || fail
|
printf 'GET / HTTP/1.0\r\n\r\n' | $HTTPD 2>/dev/null | d | grep -q 'HTTP/1.0 200 OK#%Server: eris/[0-9.a-z]*#%Connection: close#%Content-Type: text/html; charset=UTF-8#%Content-Length: 6#%Last-Modified: ..., .. ... 20.. ..:..:.. GMT#%#%james%' && pass || fail
|
||||||
|
|
||||||
title "Keepalive"
|
title "Keepalive"
|
||||||
printf 'GET / HTTP/1.1\r\n\r\nGET / HTTP/1.1\r\n\r\n' | $HTTPD 2>/dev/null | grep -c 'james' | grep -q 2 && pass || fail
|
printf 'GET / HTTP/1.1\r\n\r\nGET / HTTP/1.1\r\n\r\n' | $HTTPD 2>/dev/null | grep -c 'james' | grep -q 2 && pass || fail
|
||||||
|
@ -192,6 +193,10 @@ title "Basic CGI"
|
||||||
printf 'GET /a.cgi HTTP/1.0\r\n\r\n' | \
|
printf 'GET /a.cgi HTTP/1.0\r\n\r\n' | \
|
||||||
$HTTPD_CGI 2>/dev/null | d | grep -Eq 'HTTP/1.0 200 OK#%Server: .*#%Connection: close#%Pragma: no-cache#%Content-type: text/plain#%#%.*%GATEWAY_INTERFACE=.?CGI/1.1.?%' && pass || fail
|
$HTTPD_CGI 2>/dev/null | d | grep -Eq 'HTTP/1.0 200 OK#%Server: .*#%Connection: close#%Pragma: no-cache#%Content-type: text/plain#%#%.*%GATEWAY_INTERFACE=.?CGI/1.1.?%' && pass || fail
|
||||||
|
|
||||||
|
title "CGI chdir"
|
||||||
|
printf 'GET /a.cgi HTTP/1.0\r\n\r\n' | \
|
||||||
|
$HTTPD_CGI 2>/dev/null | d | grep -Eq '%a.cgi%' && pass || fail
|
||||||
|
|
||||||
title "REQUEST_METHOD"
|
title "REQUEST_METHOD"
|
||||||
printf 'GET /a.cgi HTTP/1.0\r\n\r\n' | \
|
printf 'GET /a.cgi HTTP/1.0\r\n\r\n' | \
|
||||||
$HTTPD_CGI 2>/dev/null | grep -Eq 'REQUEST_METHOD=.?GET.?$' && pass || fail
|
$HTTPD_CGI 2>/dev/null | grep -Eq 'REQUEST_METHOD=.?GET.?$' && pass || fail
|
||||||
|
|
Loading…
Reference in New Issue