diff options
author | lassulus <git@lassul.us> | 2023-04-28 23:49:03 +0200 |
---|---|---|
committer | lassulus <git@lassul.us> | 2023-04-28 23:49:03 +0200 |
commit | 40345c34bf6ff873e89e12ec66927cc5ec996d93 (patch) | |
tree | 648fc595556dd32ad2fa9806ccd2c7d63514c9ac /krebs/5pkgs/simple/htgen-paste | |
parent | d3b150416989aae2fa4aebf097dac96d53cd2164 (diff) |
htgen-paste: allow setting of Content-Type
Diffstat (limited to 'krebs/5pkgs/simple/htgen-paste')
-rw-r--r-- | krebs/5pkgs/simple/htgen-paste/src/htgen-paste | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/krebs/5pkgs/simple/htgen-paste/src/htgen-paste b/krebs/5pkgs/simple/htgen-paste/src/htgen-paste index bec238dca..bc806e870 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") |