blob: a6423b73e905348674b04c69a7b617d1b20bc139 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
#!/bin/sh
finish() {
echo "Status: $1"
echo "Content-type: $2"
echo
cat -
exit
}
echo "$REQUEST_URI" \
| sed -nE "s#$DRASL_HEADS_ROOT/([[:xdigit:]]{32})/([[:digit:]]+)#\1 \2#p" \
| {
IFS=' '
if ! read -r uuid size; then
echo "Bad Request" | finish "400 Bad Request" "text/plain"
fi
if test "$size" -gt 64; then
echo "Size Limit Exceeded" | finish "403 Forbidden" "text/plain"
fi
image="$(mktemp)"
trap 'rm $image' EXIT
if ./cache.sh ./head.sh "$uuid" "$size" 2>/dev/null > "$image"; then
finish "200 OK" "image/png" < "$image"
else
echo "Not Found" | finish "404 Not Found" "text/plain"
fi
}
|