fixed the built-in HTTP server to return a correct Content-Type header for '.css' files

This commit is contained in:
Jordi Sanfeliu 2014-08-06 18:24:02 +02:00
parent e39ab6c778
commit 384bea7b88
1 changed files with 3 additions and 1 deletions

View File

@ -127,6 +127,8 @@ sub http_header {
if($mimetype =~ m/(html|cgi)/) { if($mimetype =~ m/(html|cgi)/) {
print "Content-Type: text/html; charset=UTF-8\r\n"; print "Content-Type: text/html; charset=UTF-8\r\n";
} elsif($mimetype eq "css") {
print "Content-Type: text/css; charset=UTF-8\r\n";
} else { } else {
print "Content-Type: image/$mimetype;\r\n"; print "Content-Type: image/$mimetype;\r\n";
} }
@ -203,7 +205,7 @@ sub handle_request {
if(!$target || $target eq $base_url) { if(!$target || $target eq $base_url) {
$target = "index.html" unless $target; $target = "index.html" unless $target;
} }
($mimetype) = ($target =~ m/.*\.(html|cgi|png)$/); ($mimetype) = ($target =~ m/.*\.(html|cgi|css|png)$/);
$target =~ s/^\/*//; # removes leading slashes $target =~ s/^\/*//; # removes leading slashes
$target_cgi =~ s/^\/*//; # removes leading slashes $target_cgi =~ s/^\/*//; # removes leading slashes