Merge remote branch 'origin/master'

Conflicts:
	test.sh
This commit is contained in:
Neale Pickett 2012-10-30 15:41:44 -05:00
commit 1a707fea54
2 changed files with 18 additions and 2 deletions

11
cgi.c
View File

@ -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);
} }

View File

@ -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