You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
conn.SetHeader(name,val) by default overrides any previous value under the
same name.
This makes it very difficult to write multiple Set-Cookie headers, for
instance.
Headers with the same name are quite common for http servers. Just query
google.com and you'll see an example (the two Set-Cookie headers).
mhoisie@Kenna gotest $ telnet google.com 80
Trying 74.125.19.106...
Connected to google.com.
Escape character is '^]'.
GET / HTTP/1.1
HTTP/1.1 200 OK
Date: Sat, 02 Jan 2010 17:21:48 GMT
Expires: -1
Cache-Control: private, max-age=0
Content-Type: text/html; charset=ISO-8859-1
Set-Cookie:
PREF=ID=c87cc887bc1adb8c:TM=1262452908:LM=1262452908:S=UkIVKQcywQeWefwp;
expires=Mon, 02-Jan-2012 17:21:48 GMT; path=/; domain=.google.com
Set-Cookie:
NID=30=ulQicanZo3Kkybu2XhzSJSPxzgqWseouLX8fCcqxnFy6n7A90LE_nFx0PE2ihD5Z9_bCMZZqy8XG-bP_OenKaMtS9AqQY6_0bn_5Oc2LCtbj7Oik9cLqaTre-Hwprlpc;
expires=Sun, 04-Jul-2010 17:21:48 GMT; path=/; domain=.google.com; HttpOnly
Server: gws
X-XSS-Protection: 0
Transfer-Encoding: chunked
The text was updated successfully, but these errors were encountered:
There should be a way to get at the current header value.
Set means set, i.e. overwrite. But if you could get at the current
header value you could set the new value to the old one + ", " +
the one you want to add.
RFC 2616 says that sending multiple headers must be
semantically equivalent to one header with the multiple
values separated by commas.
We could replace ResponseWriter's SetHeader(k,v) with a Header() http.Header so client
code ends up looking like:
func handler(rw http.ResponseWriter, ...) {
rw.Header().Set("Content-Length", "13")
rw.Header().Add("X-Foo", "foo")
rw.Header().Add("X-Foo", "foo")
}
If we do this, though, I'd like to change other stuff in ResponseWriter at the same
time. Comments in https://golang.org/issue/1317?c=2
The text was updated successfully, but these errors were encountered: