}
FILE(){
- local file file_size file_date http_date cachedate range
- file="$1"
+ local file file_size file_date http_date cachedate range mime
+ file="$1" mime="$2"
if ! [ -f "$file" ]; then
printf 'Content-Length: 0\r\nStatus: 404 Not Found\r\n\r\n'
Status "200 OK" \
Accept-Ranges bytes \
Last-Modified "$http_date" \
- Content-Type $(file_type "$file") \
+ Content-Type "${mime:-$(file_type "$file")}" \
Content-Length $file_size
printf '\r\n'
Status "206 Partial Content" \
Accept-Ranges bytes \
Last-Modified "$http_date" \
- Content-Type $(file_type "$file") \
+ Content-Type "${mime:-$(file_type "$file")}" \
Content-Range "bytes ${range}/${file_size}" \
Content-Length "$((${range#*-} - ${range%-*} + 1))"
printf '\r\n'