1 // Copyright 2011 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
12 var headerWriteTests = []struct {
14 exclude map[string]bool
20 "Content-Type": {"text/html; charset=UTF-8"},
21 "Content-Length": {"0"},
24 "Content-Length: 0\r\nContent-Type: text/html; charset=UTF-8\r\n",
28 "Content-Length": {"0", "1", "2"},
31 "Content-Length: 0\r\nContent-Length: 1\r\nContent-Length: 2\r\n",
36 "Content-Length": {"0"},
37 "Content-Encoding": {"gzip"},
39 map[string]bool{"Content-Length": true},
40 "Content-Encoding: gzip\r\nExpires: -1\r\n",
45 "Content-Length": {"0", "1", "2"},
46 "Content-Encoding": {"gzip"},
48 map[string]bool{"Content-Length": true},
49 "Content-Encoding: gzip\r\nExpires: -1\r\n",
54 "Content-Length": {"0"},
55 "Content-Encoding": {"gzip"},
57 map[string]bool{"Content-Length": true, "Expires": true, "Content-Encoding": true},
65 "Double-Blank": {"", ""},
68 "Blank: \r\nDouble-Blank: \r\nDouble-Blank: \r\n",
72 func TestHeaderWrite(t *testing.T) {
74 for i, test := range headerWriteTests {
75 test.h.WriteSubset(&buf, test.exclude)
76 if buf.String() != test.expected {
77 t.Errorf("#%d:\n got: %q\nwant: %q", i, buf.String(), test.expected)