Use strings.ToLower on source name parameters

This commit is contained in:
Cameron Moore 2020-11-21 10:00:03 -06:00
parent 346c761ef6
commit 6f5962f8f2
2 changed files with 2 additions and 2 deletions

View file

@ -454,7 +454,7 @@ func (ha *Argument) Get(r *Request) (string, error) {
return "", errors.New("request is nil") return "", errors.New("request is nil")
} }
switch ha.Name { switch strings.ToLower(ha.Name) {
case "remote-addr": case "remote-addr":
return r.RawRequest.RemoteAddr, nil return r.RawRequest.RemoteAddr, nil
case "method": case "method":

View file

@ -262,7 +262,7 @@ var argumentGetTests = []struct {
{"header", "a", map[string]interface{}{"A": "z"}, nil, nil, nil, "z", true}, {"header", "a", map[string]interface{}{"A": "z"}, nil, nil, nil, "z", true},
{"url", "a", nil, map[string]interface{}{"a": "z"}, nil, nil, "z", true}, {"url", "a", nil, map[string]interface{}{"a": "z"}, nil, nil, "z", true},
{"payload", "a", nil, nil, map[string]interface{}{"a": "z"}, nil, "z", true}, {"payload", "a", nil, nil, map[string]interface{}{"a": "z"}, nil, "z", true},
{"request", "method", nil, nil, map[string]interface{}{"a": "z"}, &http.Request{Method: "POST", RemoteAddr: "127.0.0.1:1234"}, "POST", true}, {"request", "METHOD", nil, nil, map[string]interface{}{"a": "z"}, &http.Request{Method: "POST", RemoteAddr: "127.0.0.1:1234"}, "POST", true},
{"request", "remote-addr", nil, nil, map[string]interface{}{"a": "z"}, &http.Request{Method: "POST", RemoteAddr: "127.0.0.1:1234"}, "127.0.0.1:1234", true}, {"request", "remote-addr", nil, nil, map[string]interface{}{"a": "z"}, &http.Request{Method: "POST", RemoteAddr: "127.0.0.1:1234"}, "127.0.0.1:1234", true},
{"string", "a", nil, nil, map[string]interface{}{"a": "z"}, nil, "a", true}, {"string", "a", nil, nil, map[string]interface{}{"a": "z"}, nil, "a", true},
// failures // failures