summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAki <please@ignore.pl>2020-08-06 20:29:13 +0200
committerAki <please@ignore.pl>2020-08-06 20:29:13 +0200
commit71f20fb4dc2ebda1bef2e0621d9105fbe589d2e4 (patch)
tree7e422a0096af34fa3a798f8506cbba79106881b0
parentcab75425106eb860975fc8df79ee17da0b718a3d (diff)
downloadbrowse-71f20fb4dc2ebda1bef2e0621d9105fbe589d2e4.zip
browse-71f20fb4dc2ebda1bef2e0621d9105fbe589d2e4.tar.gz
browse-71f20fb4dc2ebda1bef2e0621d9105fbe589d2e4.tar.bz2
Changed phttp to collect more meta information
-rwxr-xr-xphttp12
1 files changed, 6 insertions, 6 deletions
diff --git a/phttp b/phttp
index eb69732..79e5df5 100755
--- a/phttp
+++ b/phttp
@@ -1,6 +1,6 @@
#!/bin/sh
PHTTP_CACHE=${PHTTP_CACHE:-/dev/shm/phttp}
-mkdir -p $PHTTP_CACHE/mimes $PHTTP_CACHE/files || exit 1
+mkdir -p $PHTTP_CACHE/meta $PHTTP_CACHE/files || exit 1
make_sum() {
echo "$@" | sha512sum | head -c72
@@ -11,13 +11,13 @@ get_with_arguments() {
local BASENAME
BASENAME=$(make_sum $@)
[ -e $PHTTP_CACHE/files/$BASENAME ] && {
- echo "$(cat $PHTTP_CACHE/mimes/$BASENAME) $PHTTP_CACHE/files/$BASENAME"
+ echo "$(cat $PHTTP_CACHE/meta/$BASENAME) $PHTTP_CACHE/files/$BASENAME"
return
}
- local TYPE
- TYPE=$(curl -sL -w "%{content_type}\n" $@ -o "$PHTTP_CACHE/files/$BASENAME") && {
- echo "$TYPE $PHTTP_CACHE/files/$BASENAME"
- echo "$TYPE" > $PHTTP_CACHE/mimes/$BASENAME
+ local META
+ META=$(curl -sL -w "%{content_type} %{url_effective}\n" $@ -o "$PHTTP_CACHE/files/$BASENAME") && {
+ echo "$META $PHTTP_CACHE/files/$BASENAME"
+ echo "$META" > $PHTTP_CACHE/meta/$BASENAME
return
}
return 1