]> Cypherpunks repositories - gostls13.git/commit
net/http: set Content-Type header in Redirect
authorDmitri Shuralyov <shurcooL@gmail.com>
Wed, 19 Jul 2017 03:59:40 +0000 (23:59 -0400)
committerBrad Fitzpatrick <bradfitz@golang.org>
Tue, 8 Aug 2017 06:09:59 +0000 (06:09 +0000)
commitfd29d03f70238abf460f56209a2ccc76dec6509e
treece48d26c9816acc7887abf1285e2fdf0a710397b
parentc3c2e453c968c7b450c59a47dc9502bd44257164
net/http: set Content-Type header in Redirect

Setting the Content-Type header explicitly allows browsers to know what
the type of the content is. Otherwise, they have to guess the type from
the content itself, which could lead to unpredictable behavior, and
increases CPU usage.

Not setting the Content-Type despite writing a body may also trigger
unwanted warnings in user middleware, and make it more difficult to
resolve valid issues where the user forgets to set Content-Type in
some situations where it should be set.

There is some precedent for doing this in http.FileServer, which
sets "Content-Type" to "text/html; charset=utf-8" before writing
<pre><a href=...></a></pre> HTML.

Change-Id: I24286827bebf4da8adee9238b8c5a94d4069c8db
Reviewed-on: https://go-review.googlesource.com/50510
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
src/net/http/server.go