mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
http: change ResponseWriter.SetHeader(k,v) to Header() accessor
Caller code needs to change:
rw.SetHeader("Content-Type", "text/plain")
to:
rw.Header().Set("Content-Type", "text/plain")
This now permits returning multiple headers
with the same name using Add:
rw.Header().Add("Set-Cookie", "..")
rw.Header().Add("Set-Cookie", "..")
This patch also fixes serialization of headers, removing newline characters.
Fixes #488
Fixes #914
R=rsc
CC=gburd, golang-dev
https://golang.org/cl/4239076
This commit is contained in:
parent
fe8639a9fb
commit
2c420ece67
16 changed files with 107 additions and 110 deletions
|
|
@ -509,7 +509,7 @@ var connected = "200 Connected to Go RPC"
|
|||
// ServeHTTP implements an http.Handler that answers RPC requests.
|
||||
func (server *Server) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
||||
if req.Method != "CONNECT" {
|
||||
w.SetHeader("Content-Type", "text/plain; charset=utf-8")
|
||||
w.Header().Set("Content-Type", "text/plain; charset=utf-8")
|
||||
w.WriteHeader(http.StatusMethodNotAllowed)
|
||||
io.WriteString(w, "405 must CONNECT\n")
|
||||
return
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue