diff options
author | tv <tv@krebsco.de> | 2017-04-13 15:39:25 +0200 |
---|---|---|
committer | tv <tv@krebsco.de> | 2017-04-13 16:27:04 +0200 |
commit | 9f0eb538f970d6fb5755ec03d8368a491bf0e418 (patch) | |
tree | 4a121f08690cab9d2e87254b1f1e728036394c15 | |
parent | 8efdb0b3ef562f583d7eab2ad781854caacfbf9c (diff) |
-rw-r--r-- | examples/paste | 7 | ||||
-rwxr-xr-x | htgen | 7 |
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' @@ -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 [1;33m$Method[m [1;4;34m$Request_URI[m 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## } |