From a96b0fcd8fb4afad4e169a3929270e2335cf4d0d Mon Sep 17 00:00:00 2001 From: =?utf8?q?Paul=20H=C3=A4nsch?= Date: Mon, 2 Jul 2018 17:26:31 +0200 Subject: [PATCH] State Content-Length in error responses to allow connection reuse --- file.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/file.sh b/file.sh index 90e8f9c..9f734c1 100755 --- a/file.sh +++ b/file.sh @@ -41,10 +41,10 @@ FILE(){ file="$1" if ! [ -f "$file" ]; then - printf 'Status: 404 Not Found\r\n\r\n' + printf 'Content-Length: 0\r\nStatus: 404 Not Found\r\n\r\n' exit 0 elif ! [ -r "$file" ]; then - printf 'Status: 403 Forbidden\r\n\r\n' + printf 'Content-Length: 0\r\nStatus: 403 Forbidden\r\n\r\n' exit 0 fi @@ -79,6 +79,7 @@ FILE(){ if [ "$file_date" -lt "$cachedate" ] 2>&-; then printf '%s: %s\r\n' \ Status '304 Not Modified' \ + Content-Length 0 \ Last-Modified "$http_date" printf '\r\n' @@ -110,6 +111,7 @@ FILE(){ elif [ "${range%-*}" -gt "${range#*-}" ]; then printf '%s: %s\r\n' \ Status "216 Range Not Satisfiable" \ + Content-Length 0 \ Content-Range \*/${file_size} printf '\r\n' fi -- 2.39.2