]> git.plutz.net Git - clickslide/commitdiff
State Content-Length in error responses to allow connection reuse
authorPaul Hänsch <paul@plutz.net>
Mon, 2 Jul 2018 15:26:31 +0000 (17:26 +0200)
committerPaul Hänsch <paul@plutz.net>
Mon, 2 Jul 2018 15:26:31 +0000 (17:26 +0200)
file.sh

diff --git a/file.sh b/file.sh
index 90e8f9c91d4b339aba048542c3c7ea453955c94d..9f734c1d2dc2e1f33619d5cbe820c5c011221cc9 100755 (executable)
--- 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