order about rw.WriteHeader & rw.Header().set, BUG ?

74 views
Skip to first unread message

lulu Lee

unread,
Jul 3, 2012, 12:20:00 AM7/3/12
to golan...@googlegroups.com
hi, all

just show the code:

内嵌图片 1

everything is fine:

内嵌图片 2

but, if i change line 12 to line 9, mean that set header after set statuscode :

内嵌图片 3

and i can't get the headers set in the response:

内嵌图片 4

is this a bug ?
golang v1.0.2 at OSX Lion 10.7.4

--
Q.Lee.lulu
学海无涯,回头是岸




--
Q.Lee.lulu
学海无涯,回头是岸

image.png
image.png
image.png
image.png

lulu Lee

unread,
Jul 2, 2012, 11:09:51 PM7/2/12
to golan...@googlegroups.com
image.png
image.png
image.png
image.png

Evan Shaw

unread,
Jul 3, 2012, 12:09:40 PM7/3/12
to lulu Lee, golan...@googlegroups.com
On Mon, Jul 2, 2012 at 11:20 PM, lulu Lee <qlee...@gmail.com> wrote:
> is this a bug ?
> golang v1.0.2 at OSX Lion 10.7.4

This is not a bug. Note the documentation for http.ResponseWriter's
Header method:

// Header returns the header map that will be sent by WriteHeader.
// Changing the header after a call to WriteHeader (or Write) has
// no effect.

- Evan
Reply all
Reply to author
Forward
0 new messages