Log directory indexes, add webfs script

This commit is contained in:
Neale Pickett 2012-11-07 19:23:28 -07:00
parent 747cd86e65
commit 1edc4dff77
3 changed files with 22 additions and 3 deletions

14
contrib/webfs Executable file
View File

@ -0,0 +1,14 @@
#! /bin/sh
PORT=8888
if [ $# = 0 ]; then
ARGS=-d
fi
addr=$(ifconfig | awk -F '[: ]+' '/inet addr/ {print $4;}' \
| grep -Fv 127.0.0.1 | head -n 1)
echo Listening on http://$addr:$PORT/
tcpsvd 0 $PORT eris -. $ARGS "$@"

6
eris.c
View File

@ -616,7 +616,7 @@ serve_idx(int fd, char *path)
html_esc(stdout, path);
printf("</title></head><body><h1>Directory Listing: ");
html_esc(stdout, path);
printf("</h1><pre>");
printf("</h1><pre>\n");
if (path[1]) {
printf("<a href=\"../\">Parent Directory</a>\n");
}
@ -661,7 +661,9 @@ serve_idx(int fd, char *path)
url_esc(stdout, name);
printf("</a>\n");
}
printf("</pre></body></html>");
printf("</pre></body></html>\n");
dolog(200, 0);
}
void

View File

@ -180,11 +180,14 @@ printf 'GET / HTTP/1.1\r\nIf-Modified-Since: %s\r\n\r\nGET / HTTP/1.0\r\n\r\n' "
H "Directory indexing"
title "Basic index"
printf 'GET /empty/ HTTP/1.0\r\n\r\n' | $HTTPD_IDX 2>/dev/null | d | grep -Fq '<h1>Directory Listing: /empty/</h1><pre><a href="../">Parent Directory</a>%</pre>' && pass || fail
printf 'GET /empty/ HTTP/1.0\r\n\r\n' | $HTTPD_IDX 2>/dev/null | d | grep -Fq '<h1>Directory Listing: /empty/</h1><pre>%<a href="../">Parent Directory</a>%</pre>' && pass || fail
title "Hidden file"
printf 'GET /subdir/ HTTP/1.0\r\n\r\n' | $HTTPD_IDX 2>/dev/null | grep -q 'hidden' && fail || pass
title "Logging"
(printf 'GET /empty/ HTTP/1.0\r\n\r\n' |
PROTO=TCP TCPREMOTEPORT=1234 TCPREMOTEIP=10.0.0.2 $HTTPD_IDX >/dev/null) 2>&1 | grep -q '^10.0.0.2:1234 200 0 (null) (null) (null) /empty/$' && pass || fail
H "CGI"