]> git.plutz.net Git - cgilite/commitdiff
correct tomestamp format for cookie expiration, empty response for redirect
authorPaul Hänsch <paul@plutz.net>
Wed, 4 Jul 2018 09:48:56 +0000 (11:48 +0200)
committerPaul Hänsch <paul@plutz.net>
Wed, 4 Jul 2018 09:48:56 +0000 (11:48 +0200)
cgilite.sh

index 46866266ea6f3250dd86106a00537a721da0a37f..1f2ebb3c9e03177d26e84a096d5c71243b00aefb 100755 (executable)
@@ -172,18 +172,21 @@ SET_COOKIE(){
   case "$1" in
     ''|0|session) expire='';;
     [+-][0-9]*)   expire="$(date -R -d @$(($(date +%s) + $1)))";;
   case "$1" in
     ''|0|session) expire='';;
     [+-][0-9]*)   expire="$(date -R -d @$(($(date +%s) + $1)))";;
-    *)           expire="$(date -R -d "$1")";;
+    *)            expire="$(date -R -d "$1")";;
   esac
   cookie="$2"
   esac
   cookie="$2"
-  
+
   printf 'Set-Cookie: %s' "$cookie"
   printf 'Set-Cookie: %s' "$cookie"
-  [ -n "$expire" ] && printf '; Expires=%s' "$expire" 
+  [ -n "$expire" ] && printf '; Expires=%s' "${expire%+????}${expire:+GMT}"
   [ $# -ge 3 ] && shift 2 && printf '; %s' "$@"
   printf '\r\n'
 }
 
 REDIRECT(){
   [ $# -ge 3 ] && shift 2 && printf '; %s' "$@"
   printf '\r\n'
 }
 
 REDIRECT(){
-  printf 'Status: 303 See Other\r\nLocation: %s\r\n\r\n' "$*"
+  printf '%s: %s\r\n'
+    Status "303 See Other" \
+    Content-Length 0 \
+    Location "$*"
+  printf '\r\n'
   exit 0
 }
   exit 0
 }
-