[
https://issues.apache.org/jira/browse/TS-4510?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15333045#comment-15333045
]
ASF GitHub Bot commented on TS-4510:
------------------------------------
Github user jpeach commented on a diff in the pull request:
https://github.com/apache/trafficserver/pull/697#discussion_r67285016
--- Diff: plugins/experimental/ts_lua/ts_lua_server_response.c ---
@@ -152,10 +172,21 @@ ts_lua_server_response_header_get(lua_State *L)
if (key && key_len) {
field_loc = TSMimeHdrFieldFind(http_ctx->server_response_bufp,
http_ctx->server_response_hdrp, key, key_len);
if (field_loc) {
- val = TSMimeHdrFieldValueStringGet(http_ctx->server_response_bufp,
http_ctx->server_response_hdrp, field_loc, -1, &val_len);
- lua_pushlstring(L, val, val_len);
- TSHandleMLocRelease(http_ctx->server_response_bufp,
http_ctx->server_response_hdrp, field_loc);
-
+ count = 0;
+ while (field_loc) {
+ val = TSMimeHdrFieldValueStringGet(http_ctx->server_response_bufp,
http_ctx->server_response_hdrp, field_loc, -1, &val_len);
+ next_field_loc =
TSMimeHdrFieldNextDup(http_ctx->server_response_bufp,
http_ctx->server_response_hdrp, field_loc);
+ lua_pushlstring(L, val, val_len);
+ count++;
+ // multiple headers with the same name must be semantically the
same as one value which is comma seperated
+ if (next_field_loc) {
+ lua_pushlstring(L, ",", 1);
+ count++;
+ }
+ TSHandleMLocRelease(http_ctx->server_response_bufp,
http_ctx->server_response_hdrp, field_loc);
+ field_loc = next_field_loc;
+ }
+ lua_concat(L, count);
--- End diff --
Ooh I didn't know about ``lua_concat``. That's cool.
> ts_lua plugin - support multiple headers with the same name
> -----------------------------------------------------------
>
> Key: TS-4510
> URL: https://issues.apache.org/jira/browse/TS-4510
> Project: Traffic Server
> Issue Type: Improvement
> Components: Lua, Plugins
> Reporter: Kit Chan
> Assignee: Kit Chan
> Fix For: 7.0.0
>
>
> Currently ts_lua plugin does not handle well when the request or response
> contains multiple header with the same name.
> We either retrieve the last value of first value of these headers and when we
> set new value to the header, we only change the first one and leave the rest
> there still.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)