diff --git a/application.go b/application.go index 1994177..7a71646 100644 --- a/application.go +++ b/application.go @@ -263,7 +263,7 @@ func (this *Application) handler(w http.ResponseWriter, req *http.Request) { //设置header mimeStr := Substr(path, strings.LastIndex(path, "."), len(path)) - //fmt.Println(mimeStr) + //类型判断并设置Content-Type if value, ok := mimeMaps[mimeStr]; ok { diff --git a/mime.go b/mime.go index 658ce76..3d0f850 100644 --- a/mime.go +++ b/mime.go @@ -1,16 +1,3 @@ -// Copyright 2014 beego Author. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. package hotime @@ -78,7 +65,7 @@ var mimeMaps = map[string]string{ ".crt": "application/pkix-cert", ".crx": "application/x-chrome-extension", ".csh": "text/x-scriptcsh", - ".css": "text/css", + ".css": "text/css;charset=utf-8", ".csv": "text/csv", ".cxx": "text/plain", ".dar": "application/x-dar", @@ -149,8 +136,8 @@ var mimeMaps = map[string]string{ ".hqx": "application/binhex", ".hta": "application/hta", ".htc": "text/x-component", - ".htm": "text/html", - ".html": "text/html", + ".htm": "text/html;charset=utf-8", + ".html": "text/html;charset=utf-8", ".htmls": "text/html", ".htt": "text/webviewhtml", ".htx": "text/html", @@ -184,7 +171,7 @@ var mimeMaps = map[string]string{ ".jpeg": "image/jpeg", ".jpg": "image/jpeg", ".jps": "image/x-jps", - ".js": "application/javascript", + ".js": "application/javascript;charset=utf-8", ".json": "application/json", ".jut": "image/jutvision", ".kar": "audio/midi",