]> git.plutz.net Git - cgilite/commitdiff
improved handling of Connection header
authorPaul Hänsch <paul@plutz.net>
Tue, 2 Jun 2020 22:55:25 +0000 (00:55 +0200)
committerPaul Hänsch <paul@plutz.net>
Tue, 2 Jun 2020 22:55:25 +0000 (00:55 +0200)
cgilite.sh

index ddad1d4811c7635c8032c08620666fec9a9b2232..bee93d86089668be13c59375026e7cfaa0464313 100755 (executable)
@@ -95,11 +95,16 @@ if [ -z "$REQUEST_METHOD" ]; then
     # Without Content-Length header, connection will terminate after
     # script.
 
-    cgilite_status='200 OK'; cgilite_response=''; cgilite_cl="Connection: close${CR}";
+    cgilite_status='200 OK'; cgilite_response=''; cgilite_cl="Connection: close${CR}${BR}";
     . "$0" | while read -r l; do case $l in
-      Status:*) cgilite_status="${l#Status: }";;
-      Content-Length:*) cgilite_cl="${l}";;
-      $CR) printf '%s %s\r\n%s%s\n\r\n' \
+      Status:*)
+        cgilite_status="${l#Status: }";;
+      Content-Length:*)
+        cgilite_cl=""
+        cgilite_response="${cgilite_response:+${cgilite_response}${BR}}${l}";;
+      Connection:*)
+        cgilite_cl="${l}${BR}";;
+      $CR) printf '%s %s\r\n%s%s\r\n' \
              'HTTP/1.1' "${cgilite_status%${CR}}" \
              "${cgilite_response}${cgilite_response:+${BR}}" "${cgilite_cl}"
            cat || kill $$