From 40345c34bf6ff873e89e12ec66927cc5ec996d93 Mon Sep 17 00:00:00 2001 From: lassulus Date: Fri, 28 Apr 2023 23:49:03 +0200 Subject: htgen-paste: allow setting of Content-Type --- krebs/5pkgs/simple/htgen-paste/src/htgen-paste | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'krebs/5pkgs') diff --git a/krebs/5pkgs/simple/htgen-paste/src/htgen-paste b/krebs/5pkgs/simple/htgen-paste/src/htgen-paste index bec238dc..bc806e87 100644 --- a/krebs/5pkgs/simple/htgen-paste/src/htgen-paste +++ b/krebs/5pkgs/simple/htgen-paste/src/htgen-paste @@ -15,8 +15,9 @@ abs_path=${Request_URI%%\?*} case "$Method $abs_path" in "GET /"[0-9a-z]*) if item=$(find_item ${abs_path#/}); then + content_type=$(cat "$item".content_type 2>/dev/null || file -ib "$item") printf 'HTTP/1.1 200 OK\r\n' - printf 'Content-Type: %s\r\n' "$(file -ib $item)" + printf 'Content-Type: %s\r\n' "$content_type" printf 'Server: %s\r\n' "$Server" printf 'Connection: close\r\n' printf 'Content-Length: %d\r\n' $(wc -c < $item) @@ -45,6 +46,10 @@ case "$Method $abs_path" in cp -v $content $item >&2 fi + if test -n ${reg_content_type-}; then + echo -n "$req_content_type" > "$item".content_type + fi + base32short=$(echo $base32 | cut -b-7) if item=$(find_item $base32short); then ref=$(echo "$ref"; echo "http://$req_host/$base32short") -- cgit v1.2.3