From 44d80696c763f4e8c8102ea8d8c570e686fbff4e Mon Sep 17 00:00:00 2001 From: =?utf8?q?Paul=20H=C3=A4nsch?= Date: Wed, 4 Jul 2018 11:48:56 +0200 Subject: [PATCH] correct tomestamp format for cookie expiration, empty response for redirect --- cgilite.sh | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) 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 } - -- 2.39.2