Skip to content
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

mime: wrong content-type return when use svg as css background-image #6378

Closed
gopherbot opened this issue Sep 13, 2013 · 10 comments
Closed

mime: wrong content-type return when use svg as css background-image #6378

gopherbot opened this issue Sep 13, 2013 · 10 comments

Comments

@gopherbot
Copy link

by ipv6.elata:

the right return content-type is image/svg+xml


Which operating system are you using?
windows 7 64bit

Which version are you using?  (run 'go version')
go1.1.2 windows/386

Please provide any additional information below.
the related source file is
http://golang.org/src/pkg/mime/type.go
but modify the registry to edit mimetypes is very trouble on winodws
I think  the easy way is add a mime type 
".svg":  "image/svg+xml", in mimeTypes
@alexbrainman
Copy link
Member

Comment 1:

Please, provide a small program to demonstrate the issue. And tell us what your program
outputs and what you think it should output instead. Thank you.
Alex

Status changed to WaitingForReply.

@rsc
Copy link
Contributor

rsc commented Nov 27, 2013

Comment 2:

Labels changed: added go1.3maybe.

@dsymonds
Copy link
Contributor

dsymonds commented Dec 2, 2013

Comment 3:

Labels changed: added priority-later, packagebug, removed priority-triage.

@rsc
Copy link
Contributor

rsc commented Dec 4, 2013

Comment 4:

Labels changed: added release-none, removed go1.3maybe.

@rsc
Copy link
Contributor

rsc commented Dec 4, 2013

Comment 5:

Labels changed: added repo-main.

@gopherbot
Copy link
Author

Comment 6 by germanium@gmx.us:

I have the same issue on Linux.
My distribution doesn't include a "mime.types" file therefore http.FileServer gives me a
mime type of "text/xml; charset=utf-8" for .svg files.
Firefox refuses to display .svg files in <img> tags unless the mime type is
"image/svg+xml".
I think it would be nice to have ".svg" in mime.mimeTypes if it is appropriate because
it is useful to display static web pages correctly.
Thanks, L

@gopherbot
Copy link
Author

Comment 7 by iacob.campia:

You can add a mime.AddExtensionType(".svg", "image/svg+xml") line (and import "mime")
and all is good. 
I had the same problem on Centos. But not because the mime file was missing, but because
it expects to start with <!DOCTYPE svg and most .svg files start with <?xml
version="1.0 ?><!DOCTYPE svg ....

@gopherbot
Copy link
Author

Comment 8 by treeder:

This happens on Google App Engine too using http.ServeFile, returns svg files with
content-type text/xml. I've even done what was suggested above, adding
mime.AddExtensionType(".svg", "image/svg+xml"), but that doesn't work.

@gopherbot
Copy link
Author

Comment 9 by treeder:

Same things happens on App Engine, adding the mime-type as above:
mime.AddExtensionType(".svg", "image/svg+xml"), seems to have fixed it.

@rsc rsc added this to the Unplanned milestone Apr 10, 2015
@odeke-em
Copy link
Member

This issue seems to have already been fixed by commit 21e47d8 through CL https://go-review.googlesource.com/#/c/7942. The CL just hadn't mentioned it.
Proof that it works here http://play.golang.org/p/gN51TN-BzZ.

@golang golang locked and limited conversation to collaborators Feb 28, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants