File tree Expand file tree Collapse file tree 1 file changed +38
-0
lines changed Expand file tree Collapse file tree 1 file changed +38
-0
lines changed Original file line number Diff line number Diff line change @@ -109,6 +109,44 @@ func TestHeaderValuesContainsToken(t *testing.T) {
109
109
}
110
110
}
111
111
112
+ func TestValidHeaderFieldName (t * testing.T ) {
113
+ tests := []struct {
114
+ in string
115
+ want bool
116
+ }{
117
+ {"" , false },
118
+ {"Accept Charset" , false },
119
+ {"Accept-Charset" , true },
120
+ {"AccepT-EncodinG" , true },
121
+ {"CONNECTION" , true },
122
+ {"résumé" , false },
123
+ }
124
+ for _ , tt := range tests {
125
+ got := ValidHeaderFieldName (tt .in )
126
+ if tt .want != got {
127
+ t .Errorf ("ValidHeaderFieldName(%q) = %t; want %t" , tt .in , got , tt .want )
128
+ }
129
+ }
130
+ }
131
+
132
+ func BenchmarkValidHeaderFieldName (b * testing.B ) {
133
+ names := []string {
134
+ "" ,
135
+ "Accept Charset" ,
136
+ "Accept-Charset" ,
137
+ "AccepT-EncodinG" ,
138
+ "CONNECTION" ,
139
+ "résumé" ,
140
+ }
141
+ b .ReportAllocs ()
142
+ b .ResetTimer ()
143
+ for i := 0 ; i < b .N ; i ++ {
144
+ for _ , name := range names {
145
+ ValidHeaderFieldName (name )
146
+ }
147
+ }
148
+ }
149
+
112
150
func TestPunycodeHostPort (t * testing.T ) {
113
151
tests := []struct {
114
152
in , want string
You can’t perform that action at this time.
0 commit comments