-
Notifications
You must be signed in to change notification settings - Fork 18.3k
Closed
Labels
Milestone
Description
Please answer these questions before submitting your issue. Thanks!
- What version of Go are you using (
go version
)?
go version go1.6.2 darwin/amd64 - What operating system and processor architecture are you using (
go env
)?
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH=""
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GO15VENDOREXPERIMENT="1"
CC="clang"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fno-common"
CXX="clang++"
CGO_ENABLED="1" - What did you do?
package main
import (
"fmt"
"net/http"
"io/ioutil"
)
func main() {
fp, err := ioutil.ReadFile("test.html")
if err != nil {
fmt.Printf("error opening file %s\n", err)
return
}
fmt.Printf("Content-type %s\n", http.DetectContentType(fp))
}
With test.html being:
<!--
this is a dummy comment
-->
<html>
this is a simple html page
</html>
output: Content-type text/plain; charset=utf-8
- What did you expect to see?
output: Content-type text/html; charset=utf-8
Basically DetectContentType should detect the '<!--' at the start of the .html file, and it does not. As soon as I remove the '<!--' tag, then the file is correctly detected as text/html
- What did you see instead?
Content-type text/plain; charset=utf-8