1 // Copyright 2010 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
5 // +build darwin dragonfly freebsd linux nacl netbsd openbsd solaris
15 var typeFiles = []string{
17 "/etc/apache2/mime.types",
18 "/etc/apache/mime.types",
21 func loadMimeFile(filename string) {
22 f, err := os.Open(filename)
28 scanner := bufio.NewScanner(f)
30 fields := strings.Fields(scanner.Text())
31 if len(fields) <= 1 || fields[0][0] == '#' {
35 for _, ext := range fields[1:] {
39 setExtensionType("."+ext, mimeType)
42 if err := scanner.Err(); err != nil {
48 for _, filename := range typeFiles {
49 loadMimeFile(filename)
53 func initMimeForTests() map[string]string {
54 typeFiles = []string{"testdata/test.types"}
55 return map[string]string{
56 ".T1": "application/test",
57 ".t2": "text/test; charset=utf-8",