From 359c80f2ced15a794a21fd3d0dba762970dbf78d Mon Sep 17 00:00:00 2001 From: Sarah Schulte Date: Mon, 21 Aug 2023 06:52:36 -0700 Subject: [PATCH] lowercase headers can be allowed i guess --- core.sh | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/core.sh b/core.sh index 693c11c..65b4680 100755 --- a/core.sh +++ b/core.sh @@ -83,7 +83,7 @@ function htmx_page() { STYLE_TEXT='' fi fi - [[ ${HTTP_HEADERS["HX-Request"]} == "true" ]] || [[ "$INTERNAL_REQUEST" == "true" ]] || cat << EOF + [[ ${HTTP_HEADERS["hx-request"]} == "true" ]] || [[ "$INTERNAL_REQUEST" == "true" ]] || cat << EOF @@ -99,7 +99,7 @@ EOF cat # meow -[[ "$INTERNAL_REQUEST" == "true" ]] || [[ ${HTTP_HEADERS["HX-Request"]} == "true" ]] || [[ ! -z "$HIDE_LOGO" ]] || cat << EOF +[[ "$INTERNAL_REQUEST" == "true" ]] || [[ ${HTTP_HEADERS["hx-request"]} == "true" ]] || [[ ! -z "$HIDE_LOGO" ]] || cat << EOF
@@ -220,26 +220,27 @@ EOF while IFS= read -r line; do line="${line%%$'\r'}" [[ -z "$line" ]] && break - HTTP_HEADERS["${line%%:*}"]="${line#*: }" + KEY="${line%%:*}" + HTTP_HEADERS["${KEY,,}"]="${line#*: }" # debug "$line" done # Parse multipart Form Data - if [[ ${HTTP_HEADERS["Content-Type"]} == "multipart/form-data; "* ]]; then - BOUNDARY="${HTTP_HEADERS["Content-Type"]}" + if [[ ${HTTP_HEADERS["content-type"]} == "multipart/form-data; "* ]]; then + BOUNDARY="${HTTP_HEADERS["content-type"]}" BOUNDARY="${BOUNDARY#*=}" fi # Read cookies (yum!) - if [[ ! -z "${HTTP_HEADERS["Cookie"]}" ]]; then + if [[ ! -z "${HTTP_HEADERS["cookie"]}" ]]; then while read -r -d ';' line; do COOKIES["${line%%=*}"]=$(urldecode "${line#*=}") done << EOF -${HTTP_HEADERS["Cookie"]}; +${HTTP_HEADERS["cookie"]}; EOF fi - CLEN=${HTTP_HEADERS["Content-Length"]} + CLEN=${HTTP_HEADERS["content-length"]} # Read multipart body if [[ ! -z "$BOUNDARY" ]]; then @@ -282,7 +283,8 @@ EOF UPLOAD_TO=$(mktemp -p uploads) state="body" else - MULTIPART_HEADERS["${PARSED%%:*}"]="${PARSED#*: }" + KEY="${PARSED%%:*}" + MULTIPART_HEADERS["${KEY,,}"]="${PARSED#*: }" fi elif [[ "$state" == "body" ]]; then if [[ "$reader" == "flushing-null" ]]; then @@ -294,7 +296,7 @@ EOF while read -r -d ';' line; do DISPOSITIONS["${line%%=*}"]=$(urldecode "${line#*=}") done << EOF -${MULTIPART_HEADERS["Content-Disposition"]}; +${MULTIPART_HEADERS["content-disposition"]}; EOF NAME=$(trim_quotes "${DISPOSITIONS[name]}") FILENAME=$(trim_quotes "${DISPOSITIONS[filename]}") @@ -325,7 +327,7 @@ EOF fi # Parse Form Data if [[ ! -z "$REQUEST_BODY" ]] && \ - [[ ${HTTP_HEADERS["Content-Type"]} == "application/x-www-form-urlencoded" ]]; then + [[ ${HTTP_HEADERS["content-type"]} == "application/x-www-form-urlencoded" ]]; then while read -r -d '&' line; do FORM_DATA["${line%%=*}"]=$(urldecode "${line#*=}") done << EOF @@ -533,9 +535,9 @@ export -f debug export -f subscribe export -f unsubscribe export -f publish -export -f event export -f header export -f end_headers +export -f event export -f htmx_page export -f findPredefinedRoutes export -f findDynamicRoutes