unset length date file suffix
file="$1"
-date="$(stat -c %Y "$file")"
+date="$(stat -Lc %Y "$file")"
# allow overriding magic file recognition
# don't use this if `file` returns type correctly
_bend="${_range#*-}"
fi
-if [ -x "$file" -o \! -r "$file" -o \! -f "$file" ]; then
+if ! [ -f "$file" ] || [ -x "$file" ] || ! grep -qm1 '' "$file" ; then
printf 'Status:403 Forbidden\r\n\r\n'
elif [ "$date" = "$cachedate" ]; then
printf 'Status:304 Not Modified\r\n'
printf 'Last-Modified: %s\r\n\r\n' "$(date -Rd "@$date")"
elif [ "$_bstart" -gt 0 ] ; then
- length="$(stat -c %s "$file")"
+ length="$(stat -Lc %s "$file")"
magic="${suffix[${file##*.}]:-$(file -bi "$file")}"
printf 'Status:206 Partial Content\r\n'
tail -c+"$(($_bstart + 1))" "$file"
else
- length="$(stat -c %s "$file")"
+ length="$(stat -Lc %s "$file")"
magic="${suffix[${file##*.}]:-$(file -bi "$file")}"
printf 'Accept-Ranges: bytes\r\n'