Skip to content

Commit

Permalink
feat: strict http headers null validation with tests (#140)
Browse files Browse the repository at this point in the history
  • Loading branch information
kruskall authored Aug 11, 2023
1 parent a636758 commit f5da0e6
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ func init() {
h := http.Header{}
for key, val := range m {
switch v := val.(type) {
case nil:
case string:
h.Add(key, v)
case []interface{}:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,8 @@ func TestHTTPHeader(t *testing.T) {
}},
{name: "valid2", input: `{"h":{"k":["a","b"]}}`, isSet: true, val: http.Header{"K": []string{"a", "b"}}},
{name: "null", input: `{"h":null}`},
{name: "null-value", input: `{"h":{"k": null}`, fail: true},
{name: "null-array", input: `{"h":{"k": [null]}`, fail: true},
{name: "invalid-type", input: `{"h":""}`, fail: true, isSet: true},
{name: "invalid-array", input: `{"h":{"k":["a",23]}}`, isSet: true, fail: true},
{name: "missing", input: `{}`},
Expand Down

0 comments on commit f5da0e6

Please sign in to comment.