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 freebsd linux netbsd openbsd plan9
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)
27 reader := bufio.NewReader(f)
29 line, err := reader.ReadString('\n')
34 fields := strings.Fields(line)
35 if len(fields) <= 1 || fields[0][0] == '#' {
39 for _, ext := range fields[1:] {
43 setExtensionType("."+ext, mimeType)
49 for _, filename := range typeFiles {
50 loadMimeFile(filename)
54 func initMimeForTests() map[string]string {
55 typeFiles = []string{"testdata/test.types"}
56 return map[string]string{
57 ".t1": "application/test",
58 ".t2": "text/test; charset=utf-8",