Skip to content
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ Functions:
```

## Websocket
!!!NOTE: This is still expiremental and only works for sendin data, not receiving!
!!!NOTE: This is still experimental and only works for sending data, not receiving!

Functions:
```
Expand Down
12 changes: 6 additions & 6 deletions bash-server.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/local/bin/bash
#!/usr/bin/env bash

# https://github.com/dylanaraps/pure-bash-bible#decode-a-percent-encoded-string
urldecode() {
Expand Down Expand Up @@ -76,18 +76,18 @@ parseGetData(){
QUERY_STRING="$get"
IFS='&' read -ra data <<<"$get"
for entry in "${data[@]}"; do
GET["${entry%%=*}"]="${entry#*:}"
GET["${entry%%=*}"]="${entry#*=}"
done
}

parsePostData(){
local entry
# Split POst data into an assoc if is a form, if not create a key raw
# Split Post data into an assoc if is a form, if not create a key raw
if [[ "${HTTP_HEADERS["Content-type"]}" == "application/x-www-form-urlencoded" ]]; then
IFS='&' read -rN "${HTTP_HEADERS["Content-Length"]}" -a data
for entry in "${data[@]}"; do
entry="${entry%%$'\r'}"
POST["${entry%%=*}"]="${entry#*:}"
POST["${entry%%=*}"]="${entry#*=}"
done
else
read -rN "${HTTP_HEADERS["Content-Length"]}" data
Expand Down Expand Up @@ -469,7 +469,7 @@ main(){
_verbose 1 "Listening on $BIND_ADDRESS port $HTTP_PORT"

serverTmpDir="$(mktemp -d)"
# Create the file, but do not zrite inside
# Create the file, but do not write inside
: > "$serverTmpDir/spawnNewProcess"

(
Expand All @@ -490,7 +490,7 @@ main(){
# XXX: Currently no other way found around it.. :(
exec {ACCEPT_FD}>&-

# remove the temporary directoru
# remove the temporary directory
rm -rf "$serverTmpDir"
) &

Expand Down