Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions bashttpd
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,11 @@ unconditionally() {
"$@" "$REQUEST_URI"
}

# Taken from https://stackoverflow.com/a/6265305/566849
uri_decode() {
echo -e "$(sed 's/+/ /g;s/%\(..\)/\\x\1/g;')"
}

# Request-Line HTTP RFC 2616 $5.1
read -r line || fail_with 400

Expand All @@ -266,6 +271,8 @@ read -r REQUEST_METHOD REQUEST_URI REQUEST_HTTP_VERSION <<<"$line"
# Only GET is supported at this time
[ "$REQUEST_METHOD" = "GET" ] || fail_with 405

REQUEST_URI=$(uri_decode <<<"$REQUEST_URI")

declare -a REQUEST_HEADERS

while read -r line; do
Expand Down