mirror of https://github.com/nealey/eris.git
fix directory redirect bug
This commit is contained in:
parent
90a0d5efa1
commit
3c4ee62af4
4
eris.c
4
eris.c
|
@ -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;
|
||||
|
|
2
test.sh
2
test.sh
|
@ -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' |
|
||||
|
|
Loading…
Reference in New Issue