fix directory redirect bug

This commit is contained in:
Neale Pickett 2012-03-11 21:53:32 -06:00
parent 90a0d5efa1
commit 3c4ee62af4
2 changed files with 3 additions and 3 deletions

4
eris.c
View File

@ -424,7 +424,6 @@ serve_idx(int fd, char *path)
printf("</a>\n");
}
printf("</pre></body></html>");
fflush(stdout);
}
void
@ -444,7 +443,7 @@ find_serve_file(char *relpath)
/* Redirect if it doesn't end with / */
if (! endswith(path, "/")) {
header(301, "Redirect");
printf("Location: %s/", path);
printf("Location: %s/\r\n", path);
eoh();
return;
}
@ -733,6 +732,7 @@ handle_request()
/* Serve the file */
cork(1);
find_serve_file(fspath);
fflush(stdout);
cork(0);
return;

View File

@ -94,7 +94,7 @@ title "Bare newline"
printf 'GET / HTTP/1.0\n\n' | $HTTPD 2>/dev/null | grep -q 'james' && pass || fail
title "No trailing slash"
printf 'GET /empty HTTP/1.0\r\n\r\n' | $HTTPD 2>/dev/null | d | grep -q '301 Redirect#%.*Location: /empty/#%' && pass || fail
printf 'GET /empty HTTP/1.0\r\n\r\n' | $HTTPD 2>/dev/null | d | grep -q '301 Redirect#%.*Location: /empty/#%#%' && pass || fail
title "Logging /"
(printf 'GET / HTTP/1.1\r\nHost: host\r\n\r\n' |