• Dmitri Shuralyov's avatar
    net/http: set Content-Type header in Redirect · fd29d03f
    Dmitri Shuralyov authored
    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/50510Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
    Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
    TryBot-Result: Gobot Gobot <gobot@golang.org>
    fd29d03f
Name
Last commit
Last update
.github Loading commit data...
api Loading commit data...
doc Loading commit data...
lib/time Loading commit data...
misc Loading commit data...
src Loading commit data...
test Loading commit data...
.gitattributes Loading commit data...
.gitignore Loading commit data...
AUTHORS Loading commit data...
CONTRIBUTING.md Loading commit data...
CONTRIBUTORS Loading commit data...
LICENSE Loading commit data...
PATENTS Loading commit data...
README.md Loading commit data...
favicon.ico Loading commit data...
robots.txt Loading commit data...