|
@@ -5,11 +5,11 @@ import (
|
|
|
"net/http"
|
|
|
)
|
|
|
|
|
|
-// mimeTypes stores the MIME content type.
|
|
|
-var mimeTypes = struct {
|
|
|
- TextPlain string
|
|
|
- OctetStream string
|
|
|
-}{"text/plain", "application/octet-stream"}
|
|
|
+// MIME content types.
|
|
|
+const (
|
|
|
+ mimeTypeTextPlain = "text/plain"
|
|
|
+ mimeTypeOctetStream = "application/octet-stream"
|
|
|
+)
|
|
|
|
|
|
// detectContentType returns a best guess representation of the MIME
|
|
|
// content type for the bytes at c. The value detected by
|
|
@@ -17,11 +17,10 @@ var mimeTypes = struct {
|
|
|
// application/octet-stream when a better guess cannot be made. The
|
|
|
// result of this detection is then run through mime.ParseMediaType()
|
|
|
// which separates the actual MIME string from any parameters.
|
|
|
-func detectContentType(c []byte) (string, map[string]string, error) {
|
|
|
- ct := http.DetectContentType(c)
|
|
|
- contentType, args, err := mime.ParseMediaType(ct)
|
|
|
+func detectContentType(c []byte) (string, error) {
|
|
|
+ contentType, _, err := mime.ParseMediaType(http.DetectContentType(c))
|
|
|
if err != nil {
|
|
|
- return "", nil, err
|
|
|
+ return "", err
|
|
|
}
|
|
|
- return contentType, args, nil
|
|
|
+ return contentType, nil
|
|
|
}
|