From 3c4ee62af49068f3716bccac08e69fd2bb3b241f Mon Sep 17 00:00:00 2001 From: Neale Pickett Date: Sun, 11 Mar 2012 21:53:32 -0600 Subject: [PATCH] fix directory redirect bug --- eris.c | 4 ++-- test.sh | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/eris.c b/eris.c index e59a423..344dfc6 100644 --- a/eris.c +++ b/eris.c @@ -424,7 +424,6 @@ serve_idx(int fd, char *path) printf("\n"); } printf(""); - 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; diff --git a/test.sh b/test.sh index 1e3d793..22599ed 100755 --- a/test.sh +++ b/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' |