Skip to content

Commit

Permalink
add static relationship of mime type. libmagic should be final
Browse files Browse the repository at this point in the history
  • Loading branch information
ikegam committed Sep 22, 2013
1 parent d6e615c commit 75830f9
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions bashttpd
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,21 @@ fail_with() {
serve_file() {
local file=$1

read -r CONTENT_TYPE < <(file -b --mime-type "$file") && \
add_response_header "Content-Type" "$CONTENT_TYPE"
CONTENT_TYPE=
case "$file" in
*\.css)
CONTENT_TYPE="text/css"
;;
*\.js)
CONTENT_TYPE="text/javascript"
;;
*)
read -r CONTENT_TYPE < <(file -b --mime-type "$file")
;;
esac

add_response_header "Content-Type" "$CONTENT_TYPE";

read -r CONTENT_LENGTH < <(stat -c'%s' "$file") && \
add_response_header "Content-Length" "$CONTENT_LENGTH"

Expand Down

0 comments on commit 75830f9

Please sign in to comment.