File tree 2 files changed +30
-4
lines changed
2 files changed +30
-4
lines changed Original file line number Diff line number Diff line change @@ -21,13 +21,13 @@ func HeaderMatching(requestMatcher models.RequestMatcher, toMatch map[string][]s
21
21
22
22
for matcherHeaderKey , matcherHeaderValue := range requestMatcherHeadersWithMatchers {
23
23
// Make everything lowercase, as headers are case insensitive
24
- for requestHeaderKey , requestHeaderValues := range toMatch {
25
- delete ( toMatch , requestHeaderKey )
26
- toMatch [strings .ToLower (requestHeaderKey )] = requestHeaderValues
24
+ toMatchWithLowerCaseKeys := make ( map [ string ][] string )
25
+ for key , value := range toMatch {
26
+ toMatchWithLowerCaseKeys [strings .ToLower (key )] = value
27
27
}
28
28
matcherHeaderValueMatched := false
29
29
30
- toMatchHeaderValues , found := toMatch [strings .ToLower (matcherHeaderKey )]
30
+ toMatchHeaderValues , found := toMatchWithLowerCaseKeys [strings .ToLower (matcherHeaderKey )]
31
31
if ! found {
32
32
matched = false
33
33
continue
Original file line number Diff line number Diff line change @@ -177,3 +177,29 @@ func Test_HeaderMatching(t *testing.T) {
177
177
}
178
178
179
179
}
180
+
181
+
182
+ func Test_HeaderMatching_NotModifyingOriginalRequestHeaders (t * testing.T ) {
183
+ RegisterTestingT (t )
184
+
185
+ requestHeaders := map [string ][]string {
186
+ "Header1" : {"val1" },
187
+ }
188
+ result := matching .HeaderMatching (models.RequestMatcher {
189
+ Headers : map [string ][]models.RequestFieldMatchers {
190
+ "HEADER1" : {
191
+ {
192
+ Matcher : matchers .Exact ,
193
+ Value : "val1" ,
194
+ },
195
+ },
196
+ },
197
+ },
198
+ requestHeaders )
199
+
200
+ Expect (result .Matched ).To (BeTrue ())
201
+ Expect (requestHeaders ).To (Equal (map [string ][]string {
202
+ "Header1" : {"val1" },
203
+ }))
204
+
205
+ }
You can’t perform that action at this time.
0 commit comments