File tree Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -85,6 +85,7 @@ func (h Header) Reset(hs Header) {
85
85
// values from hs totally overwrite existing values in h.
86
86
func (h Header ) Apply (hs Header ) {
87
87
for _ , key := range hs .Keys () {
88
+ h .Del (key )
88
89
for _ , value := range hs .Values (key ) {
89
90
h .Add (key , value )
90
91
}
Original file line number Diff line number Diff line change 3
3
package fsthttp
4
4
5
5
import (
6
+ "reflect"
6
7
"testing"
7
8
)
8
9
@@ -16,3 +17,19 @@ func TestHeaderBasics(t *testing.T) {
16
17
t .Errorf ("Host: want %q, have %q" , want , have )
17
18
}
18
19
}
20
+
21
+ func TestHeaderApply (t * testing.T ) {
22
+ t .Parallel ()
23
+
24
+ h := NewHeader ()
25
+ h .Add ("Host" , "zombo.com" )
26
+
27
+ h2 := NewHeader ()
28
+ h2 .Add ("Host" , "zombo2.com" )
29
+
30
+ h .Apply (h2 )
31
+
32
+ if got , want := h .Values ("Host" ), []string {"zombo2.com" }; ! reflect .DeepEqual (got , want ) {
33
+ t .Errorf ("Host: got %q, want %q" , got , want )
34
+ }
35
+ }
You can’t perform that action at this time.
0 commit comments