appengine icon indicating copy to clipboard operation
appengine copied to clipboard

httpserver: ResponseWriter not using DetectContentType

Open rsc opened this issue 8 years ago • 3 comments

Attached is a simple app that serves / (html), /text (text), and /png (a png). It works fine in the dev app server and as a standalone Go program, but uploaded to App Engine the ResponseWriter implementation seems not to call http.DetectContentType to fill in the Content-Type header. Instead App Engine seems to send back text/html; charset=utf-8 all the time. This is unfortunate for /text and useless for /png.

Can we get this fixed? Strictly speaking it is not a requirement that all ResponseWriter implementations use DetectContentType, but we've arranged a bit of a soft standard that all of them do.

Thanks.

x.go.txt

rsc avatar Feb 02 '17 21:02 rsc

(On the flip side, I love the fact that writing files to cloud storage uses DetectContentType to set the Content-Type; that makes the Go libraries better than gsutil cp!)

rsc avatar Feb 02 '17 21:02 rsc

FYI, I don't see an attachment.

dsymonds avatar Feb 02 '17 21:02 dsymonds

Thanks @dsymonds, now attached to top message. I went through the motions the first time but missed the quite well-hidden "We don't support that file type" error message from the GitHub UI. Renamed to x.go.txt.

rsc avatar Feb 02 '17 21:02 rsc