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
16 osInitMime
= initMimeUnix
19 var typeFiles
= []string{
21 "/etc/apache2/mime.types",
22 "/etc/apache/mime.types",
25 func loadMimeFile(filename
string) {
26 f
, err
:= os
.Open(filename
)
32 scanner
:= bufio
.NewScanner(f
)
34 fields
:= strings
.Fields(scanner
.Text())
35 if len(fields
) <= 1 || fields
[0][0] == '#' {
39 for _
, ext
:= range fields
[1:] {
43 setExtensionType("."+ext
, mimeType
)
46 if err
:= scanner
.Err(); err
!= nil {
52 for _
, filename
:= range typeFiles
{
53 loadMimeFile(filename
)
57 func initMimeForTests() map[string]string {
58 typeFiles
= []string{"testdata/test.types"}
59 return map[string]string{
60 ".T1": "application/test",
61 ".t2": "text/test; charset=utf-8",