net/http: FileServer sets wrong content type when 404 #24985
Closed
Labels
Comments
@linkerlin as I mentioned over in gopherjs/gopherjs#802 (comment), I think this is more of an issue with Chrome reporting what is a derivative error, rather than As a result, I'll close this for now, but please do say if you think we've reached the wrong conclusion. Thanks |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
What version of Go are you using (
go version
)?v1.10.1
Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?GOARCH="amd64"
GOBIN=""
GOCACHE="/home/linker/.cache/go-build"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/linker/go"
GORACE=""
GOROOT="/home/linker/go111"
GOTMPDIR=""
GOTOOLDIR="/home/linker/go111/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build206124006=/tmp/go-build -gno-record-gcc-switches"
What did you do?
The
net/http.FileServer
usesnet/http.ServeContent
to automatically detect the content type of the 404 response body and concludes, rightly, that it is text/plain.When the
X-Content-Type-Options: nosniff
is set to header, the browser will argue:Refused to execute script from 'http://localhost:8080/xxxxxxxx.js' because its MIME type ('text/plain') is not executable, and strict MIME type checking is enabled.
I think it's a bug.
REF: X-Content-Type-Options: nosniff
The text was updated successfully, but these errors were encountered: