From: Paul Hänsch Date: Wed, 4 Jul 2018 09:48:56 +0000 (+0200) Subject: correct tomestamp format for cookie expiration, empty response for redirect X-Git-Url: https://git.plutz.net/?a=commitdiff_plain;h=44d80696c763f4e8c8102ea8d8c570e686fbff4e;p=cgilite correct tomestamp format for cookie expiration, empty response for redirect --- diff --git a/cgilite.sh b/cgilite.sh index 4686626..1f2ebb3 100755 --- a/cgilite.sh +++ b/cgilite.sh @@ -172,18 +172,21 @@ SET_COOKIE(){ 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" - + 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(){ - 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 } -