-
Notifications
You must be signed in to change notification settings - Fork 17.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
net/http: DetectContextType: recognize svg file as image/svg+xml #15888
Comments
I added extra logic to my code.
It fix my problem, although don't feel nice. If you feel don't need the feature. Please close this. |
Marking as 1.8 to decide whether or not to do it in 1.8. It would help to know whether other systems, such as the file command, recognize SVG files, and how they do it. |
Landed here with the same problem. The $ file -i /tmp/foo.svg
/tmp/foo.svg: image/svg+xml; charset=us-ascii |
http.DetectContentType is documented to be an implementation of https://mimesniff.spec.whatwg.org/ and that mimesniff spec doesn't define svg. And as you found, mime.TypeByExtension has ".svg" in its built-in table: https://github.com/golang/go/blob/release-branch.go1.6/src/mime/type.go#L35 So I don't think there's anything to do here. |
@bradfitz actually I reported an issue to whatwg whatwg/mimesniff#7, when this issue was filed here so that perhaps if they could define its spec, they could work on it, add it to the spec and we could add it in here. The issue that I filed is still open, but from the looks of it doesn't seem like they'll be adding it in. If they add it in, I'll ping this bug and we can see what we can. |
What version of Go are you using (
go version
)?go version go1.6.2 darwin/amd64
What did you do?
I want to upload svg file to aws s3. I use
http.DetectContentType(buffer)
to get the content type.I really want the
http.DetectContentType(buffer)
; backimage/svg+xml
replacetext/xml; charset=utf-8
. Because the browser don't show the svg images when<img src="s3/a-svg-file.svg">
if you give browser ContentType:text/xml; charset=utf-8
.I think it's more suit for web develop.
What did you expect to see?
image/svg+xml
If the function out of
http.DetectContentType(buffer)
scope or you have suggestions for me. Welcome to reply.Thank you very much and sorry for my bad English.
The text was updated successfully, but these errors were encountered: