mirror of
https://github.com/golang/go
synced 2024-11-24 22:47:58 -07:00
http: write Header keys with empty values
R=golang-dev, rsc, r CC=golang-dev https://golang.org/cl/4630052
This commit is contained in:
parent
922ceaddd2
commit
9ee83f546f
@ -62,9 +62,6 @@ func (h Header) WriteSubset(w io.Writer, exclude map[string]bool) os.Error {
|
||||
v = strings.Replace(v, "\n", " ", -1)
|
||||
v = strings.Replace(v, "\r", " ", -1)
|
||||
v = strings.TrimSpace(v)
|
||||
if v == "" {
|
||||
continue
|
||||
}
|
||||
if _, err := fmt.Fprintf(w, "%s: %s\r\n", k, v); err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -57,6 +57,16 @@ var headerWriteTests = []struct {
|
||||
map[string]bool{"Content-Length": true, "Expires": true, "Content-Encoding": true},
|
||||
"",
|
||||
},
|
||||
{
|
||||
Header{
|
||||
"Nil": nil,
|
||||
"Empty": {},
|
||||
"Blank": {""},
|
||||
"Double-Blank": {"", ""},
|
||||
},
|
||||
nil,
|
||||
"Blank: \r\nDouble-Blank: \r\nDouble-Blank: \r\n",
|
||||
},
|
||||
}
|
||||
|
||||
func TestHeaderWrite(t *testing.T) {
|
||||
|
Loading…
Reference in New Issue
Block a user