summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--examples/paste7
-rwxr-xr-xhtgen7
2 files changed, 7 insertions, 7 deletions
diff --git a/examples/paste b/examples/paste
index 79d48aa..17f34e9 100644
--- a/examples/paste
+++ b/examples/paste
@@ -12,7 +12,7 @@ find_item() {
case "$Method $Request_URI" in
"GET /"[0-9a-z]*)
- if item=$(find_item ${Request_URI:1}); then
+ if item=$(find_item ${Request_URI#/}); then
printf 'HTTP/1.1 200 OK\r\n'
printf 'Content-Type: %s\r\n' "$(file -ib $item)"
printf 'Server: %s\r\n' "$Server"
@@ -43,8 +43,9 @@ case "$Method $Request_URI" in
cp -v $content $item >&2
fi
- if item=$(find_item ${base32:0:7}); then
- ref=$(echo "$ref"; echo "http://$req_host/${base32:0:7}")
+ base32short=$(echo $base32 | cut -b-7)
+ if item=$(find_item $base32short); then
+ ref=$(echo "$ref"; echo "http://$req_host/$base32short")
fi
printf 'HTTP/1.1 200 OK\r\n'
diff --git a/htgen b/htgen
index 5ea88fb..562f092 100755
--- a/htgen
+++ b/htgen
@@ -34,7 +34,7 @@ EOF
## date. {{{
date=$(date '+%Y-%m-%d %H:%M:%S')
-cat>&2<<EOF
+cat 1>&2 <<EOF
# ${TCPREMOTEHOST-}[$TCPREMOTEIP]:$TCPREMOTEPORT connected at $date over $PROTO
EOF
@@ -59,7 +59,7 @@ eval "$(echo "$Request_Line" | sed -rn '
# EOF
## debug
-cat>&2<<EOF
+cat 1>&2 <<EOF
$Method $Request_URI HTTP/$HTTP_Version
EOF
## }}}
@@ -76,8 +76,7 @@ while read -r line; do
;;
[A-Za-z][0-9A-Za-z-]*:*)
k=${line%%:*}
- k=${k//-/_}
- k=${k,,}
+ k=$(echo "$k" | tr [:upper:]- [:lower:]_)
k=req_$k
v=${line#*:}
v=${v## }