-
Notifications
You must be signed in to change notification settings - Fork 352
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
script: support multiple header values #3013
script: support multiple header values #3013
Conversation
Introduce `add` and `values` methods to set and get multiple header values. Signed-off-by: Alexander Yastrebov <alexander.yastrebov@zalando.de>
if k:lower() == "authorization" then | ||
table.insert(t, k) | ||
table.insert(t, ": TRUNCATED\r\n") | ||
else | ||
table.insert(t, k) | ||
table.insert(t, ": ") | ||
table.insert(t, v) | ||
table.insert(t, table.concat(header.values(k), " ")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is what logHeader
filter does.
@@ -677,6 +683,30 @@ func setRequestHeader(f filters.FilterContext) func(*lua.LState) int { | |||
} | |||
} | |||
|
|||
func addRequestHeader(f filters.FilterContext) func(*lua.LState) int { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be possible to generalize this and reuse for request and response headers but for simplicity I decided to introduce separate functions to follow the style of existing single value setters/getters and also because they return closures.
expectedRequestHeader: http.Header{ | ||
"Foo": []string{"Bar", "Baz"}, | ||
"Qux": []string{"Bar, Baz"}, | ||
"Absent-Length": []string{"0"}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we test Foo-Length
(I expect it to be 2) and Qux-Length
(I expect it to be 1) here as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added this case to show that length of empty values is zero
👍 |
1 similar comment
👍 |
Introduce
add
andvalues
methods to set and get multiple header values.