svn path=/trunk/; revision=27
# along with shcgi. If not, see <http://www.gnu.org/licenses/>.
# along with shcgi. If not, see <http://www.gnu.org/licenses/>.
+unset length date file suffix
file="$_EXEC/static/$STATIC"
date="$(stat -c %Y "$file")"
file="$_EXEC/static/$STATIC"
date="$(stat -c %Y "$file")"
+# allow overriding magic file recognition
+# don't use this if `file` returns type correctly
+declare -A suffix
+suffix[css]="text/css"
+
if [ -x "$file" -o \! -r "$file" -o \! -f "$file" ]; then
printf 'HTTP/1.1 403 Forbidden\n\n'
elif [ "$date" = "$HTTP_IF_NONE_MATCH" ]; then
printf 'HTTP/1.1 304 Not Modified\n\n'
else
length="$(stat -c %s "$file")"
if [ -x "$file" -o \! -r "$file" -o \! -f "$file" ]; then
printf 'HTTP/1.1 403 Forbidden\n\n'
elif [ "$date" = "$HTTP_IF_NONE_MATCH" ]; then
printf 'HTTP/1.1 304 Not Modified\n\n'
else
length="$(stat -c %s "$file")"
- magic="$(file -bi "$file")"
+ magic="${suffix[${file##*.}]:-$(file -bi "$file")}"
printf 'Etag: %s\r\n' "$date"
printf 'Content-Type: %s\r\n' "${magic:-all/all}"
printf 'Etag: %s\r\n' "$date"
printf 'Content-Type: %s\r\n' "${magic:-all/all}"