Skip to content

Commit 359c80f

Browse files
committed
lowercase headers can be allowed i guess
1 parent bf05fc6 commit 359c80f

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

core.sh

+14-12
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ function htmx_page() {
8383
STYLE_TEXT='<link rel="stylesheet" href="/static/tailwind.css">'
8484
fi
8585
fi
86-
[[ ${HTTP_HEADERS["HX-Request"]} == "true" ]] || [[ "$INTERNAL_REQUEST" == "true" ]] || cat << EOF
86+
[[ ${HTTP_HEADERS["hx-request"]} == "true" ]] || [[ "$INTERNAL_REQUEST" == "true" ]] || cat << EOF
8787
<!doctype html>
8888
<html>
8989
<head>
@@ -99,7 +99,7 @@ EOF
9999

100100
cat # meow
101101

102-
[[ "$INTERNAL_REQUEST" == "true" ]] || [[ ${HTTP_HEADERS["HX-Request"]} == "true" ]] || [[ ! -z "$HIDE_LOGO" ]] || cat << EOF
102+
[[ "$INTERNAL_REQUEST" == "true" ]] || [[ ${HTTP_HEADERS["hx-request"]} == "true" ]] || [[ ! -z "$HIDE_LOGO" ]] || cat << EOF
103103
<div id="signature">
104104
<a href="https://github.com/cgsdev0/bash-stack" target="_blank">
105105
<svg xmlns="http://www.w3.org/2000/svg" width="224" height="256" viewBox="0 0 224 256"><path fill="#FFF" d="M207.953 52.162L127.317 4.287a30.372 30.372 0 0 0-31.114 0L15.55 52.162A32.165 32.165 0 0 0 0 79.869v95.734a32.165 32.165 0 0 0 15.55 27.691l80.636 47.859a30.388 30.388 0 0 0 31.115 0l80.636-47.859a32.165 32.165 0 0 0 15.566-27.707V79.869a32.165 32.165 0 0 0-15.55-27.707Z"/><path fill="#2F3A3E" d="m208.412 52.277l-80.814-47.98a30.439 30.439 0 0 0-31.184 0l-80.83 47.98A32.236 32.236 0 0 0 0 80.045v95.945a32.236 32.236 0 0 0 15.584 27.752l80.814 47.964a30.455 30.455 0 0 0 31.183 0l80.814-47.964a32.236 32.236 0 0 0 15.6-27.769V80.045a32.236 32.236 0 0 0-15.583-27.768ZM99.23 246.803l-80.814-47.964A26.604 26.604 0 0 1 5.6 175.989V80.046a26.588 26.588 0 0 1 12.816-22.849L99.23 9.216a24.92 24.92 0 0 1 25.536 0l80.749 47.98a26.426 26.426 0 0 1 12.412 18.48c-2.687-5.712-8.723-7.282-15.762-3.236l-76.396 47.316c-9.531 5.551-16.554 11.814-16.57 23.303v94.213c0 6.877 2.767 11.327 7.039 12.638a24.759 24.759 0 0 1-4.24.405a25.034 25.034 0 0 1-12.768-3.512Z"/><path fill="#3AB14A" d="m187.007 185.06l-20.086 12.013a1.47 1.47 0 0 0-.92 1.308v5.28c0 .646.435.904.968.597l20.394-12.4a1.616 1.616 0 0 0 .613-1.615v-4.634c-.016-.598-.484-.856-.969-.55Z"/><path fill="#FFF" d="M144.263 140.832c.646-.323 1.179 0 1.195.92l.064 7.008a12.917 12.917 0 0 1 7.718-.937c.501.13.71.808.517 1.615l-1.534 6.152a2.648 2.648 0 0 1-.694 1.227a1.615 1.615 0 0 1-.404.29a.92.92 0 0 1-.597.098a10.237 10.237 0 0 0-7.444 1.194a9.349 9.349 0 0 0-5.506 8.284c0 3.229 1.615 4.117 7.25 4.214c7.444.13 10.673 3.375 10.754 10.883a26.69 26.69 0 0 1-9.882 20.135l.13 6.878a2.519 2.519 0 0 1-1.18 2.1l-4.068 2.34c-.646.323-1.18 0-1.195-.904v-6.765c-3.488 1.453-7.024 1.792-9.285.888c-.42-.162-.613-.791-.436-1.518l1.47-6.216a2.6 2.6 0 0 1 .726-1.292c.115-.11.246-.203.388-.275a.807.807 0 0 1 .662 0c2.878.78 5.948.392 8.541-1.081a11.173 11.173 0 0 0 6.314-9.688c0-3.488-1.922-4.941-6.459-4.974c-5.861 0-11.303-1.13-11.416-9.688a25.027 25.027 0 0 1 9.462-19.15l-.29-7.04a2.503 2.503 0 0 1 1.178-2.13l4.021-2.568Z"/></svg>
@@ -220,26 +220,27 @@ EOF
220220
while IFS= read -r line; do
221221
line="${line%%$'\r'}"
222222
[[ -z "$line" ]] && break
223-
HTTP_HEADERS["${line%%:*}"]="${line#*: }"
223+
KEY="${line%%:*}"
224+
HTTP_HEADERS["${KEY,,}"]="${line#*: }"
224225
# debug "$line"
225226
done
226227

227228
# Parse multipart Form Data
228-
if [[ ${HTTP_HEADERS["Content-Type"]} == "multipart/form-data; "* ]]; then
229-
BOUNDARY="${HTTP_HEADERS["Content-Type"]}"
229+
if [[ ${HTTP_HEADERS["content-type"]} == "multipart/form-data; "* ]]; then
230+
BOUNDARY="${HTTP_HEADERS["content-type"]}"
230231
BOUNDARY="${BOUNDARY#*=}"
231232
fi
232233

233234
# Read cookies (yum!)
234-
if [[ ! -z "${HTTP_HEADERS["Cookie"]}" ]]; then
235+
if [[ ! -z "${HTTP_HEADERS["cookie"]}" ]]; then
235236
while read -r -d ';' line; do
236237
COOKIES["${line%%=*}"]=$(urldecode "${line#*=}")
237238
done << EOF
238-
${HTTP_HEADERS["Cookie"]};
239+
${HTTP_HEADERS["cookie"]};
239240
EOF
240241
fi
241242

242-
CLEN=${HTTP_HEADERS["Content-Length"]}
243+
CLEN=${HTTP_HEADERS["content-length"]}
243244

244245
# Read multipart body
245246
if [[ ! -z "$BOUNDARY" ]]; then
@@ -282,7 +283,8 @@ EOF
282283
UPLOAD_TO=$(mktemp -p uploads)
283284
state="body"
284285
else
285-
MULTIPART_HEADERS["${PARSED%%:*}"]="${PARSED#*: }"
286+
KEY="${PARSED%%:*}"
287+
MULTIPART_HEADERS["${KEY,,}"]="${PARSED#*: }"
286288
fi
287289
elif [[ "$state" == "body" ]]; then
288290
if [[ "$reader" == "flushing-null" ]]; then
@@ -294,7 +296,7 @@ EOF
294296
while read -r -d ';' line; do
295297
DISPOSITIONS["${line%%=*}"]=$(urldecode "${line#*=}")
296298
done << EOF
297-
${MULTIPART_HEADERS["Content-Disposition"]};
299+
${MULTIPART_HEADERS["content-disposition"]};
298300
EOF
299301
NAME=$(trim_quotes "${DISPOSITIONS[name]}")
300302
FILENAME=$(trim_quotes "${DISPOSITIONS[filename]}")
@@ -325,7 +327,7 @@ EOF
325327
fi
326328
# Parse Form Data
327329
if [[ ! -z "$REQUEST_BODY" ]] && \
328-
[[ ${HTTP_HEADERS["Content-Type"]} == "application/x-www-form-urlencoded" ]]; then
330+
[[ ${HTTP_HEADERS["content-type"]} == "application/x-www-form-urlencoded" ]]; then
329331
while read -r -d '&' line; do
330332
FORM_DATA["${line%%=*}"]=$(urldecode "${line#*=}")
331333
done << EOF
@@ -533,9 +535,9 @@ export -f debug
533535
export -f subscribe
534536
export -f unsubscribe
535537
export -f publish
536-
export -f event
537538
export -f header
538539
export -f end_headers
540+
export -f event
539541
export -f htmx_page
540542
export -f findPredefinedRoutes
541543
export -f findDynamicRoutes

0 commit comments

Comments
 (0)