@@ -83,26 +83,34 @@ def test_overwrite_singular_header(self):
83
83
self .assertNotIn ("tempesta" , list (server .last_request .headers .find_all ("host" )))
84
84
85
85
def test_overwrite_non_singular_header (self ):
86
- """New value for header must be added to old value as list ."""
86
+ """New value for header must not be added."""
87
87
self .directive = f"{ self .directive } _hdr_add"
88
88
client , server = self .base_scenario (
89
89
config = f'{ self .directive } Content-Encoding "br";\n ' ,
90
- expected_headers = [("content-encoding" , "gzip, br " )],
90
+ expected_headers = [("content-encoding" , "gzip" )],
91
91
)
92
92
if self .directive == "req_hdr_add" :
93
- self .assertNotIn ("gzip " , list (server .last_request .headers .find_all ("content-encoding" )))
93
+ self .assertNotIn ("br " , list (server .last_request .headers .find_all ("content-encoding" )))
94
94
else :
95
- self .assertNotIn ("gzip " , list (client .last_response .headers .items ("content-encoding" )))
95
+ self .assertNotIn ("br " , list (client .last_response .headers .find_all ("content-encoding" )))
96
96
97
97
def test_add_exist_header (self ):
98
98
"""Header will be modified if 'header-value' is in base request/response."""
99
99
self .directive = f"{ self .directive } _hdr_add"
100
- self .base_scenario (
100
+ client , server = self .base_scenario (
101
101
config = f'{ self .directive } x-my-hdr "original text";\n ' ,
102
102
expected_headers = [("x-my-hdr" , "original text, original text" )],
103
103
)
104
+ if self .directive == "req_hdr_add" :
105
+ self .assertNotIn (
106
+ "original text" , list (server .last_request .headers .find_all ("x-my-hdr" ))
107
+ )
108
+ else :
109
+ self .assertNotIn (
110
+ "original text" , list (client .last_response .headers .find_all ("x-my-hdr" ))
111
+ )
104
112
105
- def test_add_large_header (self ):
113
+ def test_set_large_header (self ):
106
114
self .directive = f"{ self .directive } _hdr_set"
107
115
self .base_scenario (
108
116
config = f'{ self .directive } x-my-hdr "{ "12345" * 2000 } ";\n ' ,
@@ -176,6 +184,7 @@ def test_overwrite_singular_header(self):
176
184
)
177
185
178
186
self .assertNotIn ('"asd"' , list (client .last_response .headers .find_all ("Etag" )))
187
+ self .assertNotIn ("asd" , list (client .last_response .headers .find_all ("Etag" )))
179
188
self .assertNotIn ('"qwe", "asd"' , list (client .last_response .headers .find_all ("Etag" )))
180
189
181
190
@@ -189,6 +198,7 @@ class TestReqHeaderH2(H2Config, TestReqHeader):
189
198
(":path" , "/" ),
190
199
(":scheme" , "https" ),
191
200
(":method" , "GET" ),
201
+ ("host" , "localhost" ),
192
202
("x-my-hdr" , "original text" ),
193
203
("x-my-hdr" , "original text" ),
194
204
("content-encoding" , "gzip" ),
@@ -222,5 +232,5 @@ def test_add_header_from_dynamic_table(self):
222
232
self .assertIn (b"\xbe " , client .response_buffer )
223
233
224
234
225
- class TestCachedRespHeaderH2 (H2Config , TestCachedRespHeader ):
226
- pass
235
+ class TestCachedRespHeaderH2 (TestRespHeaderH2 ):
236
+ cache = True
0 commit comments