mirror of https://github.com/nealey/eris.git
Fix 302 bug, found another fnord bug
This commit is contained in:
parent
f066042785
commit
669fcc25a4
|
@ -114,6 +114,9 @@ title "HTTP/1.1 default keepalive"
|
|||
ls / >/dev/null
|
||||
printf 'GET / HTTP/1.1\r\nHost: a\r\n\r\n') | $HTTPD 2>/dev/null | grep -c '^HTTP/' | grep -q 2 && pass || fail
|
||||
|
||||
# 8. Should parse "Thursday"; instead assumes all day names are 6 characters long
|
||||
title "RFC 850 Date"
|
||||
printf 'GET / HTTP/1.0\r\nIf-Modified-Since: Thursday, 27-Feb-30 12:12:12 GMT\r\n\r\n' | $HTTPD 2>/dev/null | grep -q '304 Not Changed' && pass || fail
|
||||
|
||||
cat <<EOD
|
||||
-----------------------------------------
|
||||
|
|
41
eris.c
41
eris.c
|
@ -754,30 +754,20 @@ timerfc(const char *s)
|
|||
{0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334},
|
||||
{0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335}
|
||||
};
|
||||
unsigned sec,
|
||||
min,
|
||||
hour,
|
||||
day,
|
||||
mon,
|
||||
year;
|
||||
char month[3];
|
||||
int c;
|
||||
unsigned n;
|
||||
char flag;
|
||||
char state;
|
||||
char isctime;
|
||||
enum { D_START, D_END, D_MON, D_DAY, D_YEAR, D_HOUR, D_MIN, D_SEC };
|
||||
|
||||
sec = 60;
|
||||
min = 60;
|
||||
hour = 24;
|
||||
day = 32;
|
||||
unsigned sec = 60,
|
||||
min = 60,
|
||||
hour = 24,
|
||||
day = 32,
|
||||
mon,
|
||||
year = 1969;
|
||||
isctime = 0;
|
||||
month[0] = 0;
|
||||
state = D_START;
|
||||
n = 0;
|
||||
flag = 1;
|
||||
char month[3] = {0, 0, 0};
|
||||
int c;
|
||||
unsigned n = 0;
|
||||
char flag = 1;
|
||||
char state = D_START;
|
||||
char isctime = 0;
|
||||
|
||||
do {
|
||||
c = *s++;
|
||||
switch (state) {
|
||||
|
@ -1693,6 +1683,7 @@ main(int argc, char *argv[], const char *const *envp)
|
|||
}
|
||||
}
|
||||
|
||||
retcode = 0;
|
||||
{
|
||||
int fd;
|
||||
if ((fd = doit(headerbuf, headerlen, url)) >= 0) {
|
||||
|
@ -1774,7 +1765,7 @@ main(int argc, char *argv[], const char *const *envp)
|
|||
} else {
|
||||
fflush(stdout);
|
||||
}
|
||||
} else {
|
||||
} else if (! retcode) {
|
||||
retcode = 404;
|
||||
}
|
||||
}
|
||||
|
@ -1796,9 +1787,9 @@ main(int argc, char *argv[], const char *const *envp)
|
|||
case 416:
|
||||
badrequest(416, "Requested Range Not Satisfiable", "");
|
||||
case 304:
|
||||
badrequest(304, "Not Changed", "");
|
||||
badrequest(304, "Not Changed", NULL);
|
||||
case 500:
|
||||
badrequest(500, "Internal Server Error", "");
|
||||
badrequest(500, "Internal Server Error", NULL);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
40
test.sh
40
test.sh
|
@ -5,32 +5,24 @@
|
|||
: ${HTTPD_IDX:=./eris -d}
|
||||
|
||||
H () {
|
||||
echo
|
||||
echo "$@"
|
||||
echo "==================================="
|
||||
echo
|
||||
}
|
||||
|
||||
BR () {
|
||||
echo
|
||||
echo "-----------------------------------"
|
||||
echo
|
||||
section="$*"
|
||||
printf "\n%-20s: " "$*"
|
||||
}
|
||||
|
||||
title() {
|
||||
printf "* %-50s: " "$1"
|
||||
thistest="$1"
|
||||
tests=$(expr $tests + 1)
|
||||
}
|
||||
|
||||
successes=0
|
||||
pass () {
|
||||
echo 'ok'
|
||||
printf '.'
|
||||
successes=$(expr $successes + 1)
|
||||
}
|
||||
|
||||
failures=0
|
||||
fail () {
|
||||
echo 'FAIL'
|
||||
printf '(%s)' "$thistest"
|
||||
failures=$(expr $failures + 1)
|
||||
}
|
||||
|
||||
|
@ -82,6 +74,24 @@ title "Logging /index.html"
|
|||
PROTO=TCP TCPREMOTEPORT=1234 TCPREMOTEIP=10.0.0.2 $HTTPD >/dev/null) 2>&1 | grep -q '^10.0.0.2 200 6 host (null) (null) /index.html$' && pass || fail
|
||||
|
||||
|
||||
H "If-Modified-Since"
|
||||
title "Has been modified"
|
||||
printf 'GET / HTTP/1.0\r\nIf-Modified-Since: Sun, 27 Feb 1980 12:12:12 GMT\r\n\r\n' | $HTTPD 2>/dev/null | grep -q '200 OK' && pass || fail
|
||||
|
||||
title "RFC 822 Date"
|
||||
printf 'GET / HTTP/1.0\r\nIf-Modified-Since: Sun, 27 Feb 2030 12:12:12 GMT\r\n\r\n' | $HTTPD 2>/dev/null | grep -q '304 Not Changed' && pass || fail
|
||||
|
||||
title "RFC 850 Date"
|
||||
printf 'GET / HTTP/1.0\r\nIf-Modified-Since: Sunday, 27-Feb-30 12:12:12 GMT\r\n\r\n' | $HTTPD 2>/dev/null | grep -q '304 Not Changed' && pass || fail
|
||||
|
||||
title "RFC 850 Thursday"
|
||||
printf 'GET / HTTP/1.0\r\nIf-Modified-Since: Thursday, 27-Feb-30 12:12:12 GMT\r\n\r\n' | $HTTPD 2>/dev/null | grep -q '304 Not Changed' && pass || fail
|
||||
|
||||
title "ANSI C Date"
|
||||
printf 'GET / HTTP/1.0\r\nIf-Modified-Since: Sun Feb 27 12:12:12 2030\r\n\r\n' | $HTTPD 2>/dev/null | grep -q '304 Not Changed' && pass || fail
|
||||
|
||||
|
||||
|
||||
H "Directory indexing"
|
||||
|
||||
title "Basic index"
|
||||
|
@ -139,8 +149,8 @@ title "HTTP/1.1 default keepalive"
|
|||
ls / >/dev/null
|
||||
printf 'GET / HTTP/1.1\r\nHost: a\r\n\r\n') | $HTTPD 2>/dev/null | grep -c '^HTTP/' | grep -q 2 && pass || fail
|
||||
|
||||
BR
|
||||
|
||||
echo
|
||||
echo
|
||||
echo "$successes of $tests tests passed ($failures failed)."
|
||||
|
||||
exit $failures
|
||||
|
|
Loading…
Reference in New Issue