[
https://issues.apache.org/jira/browse/TS-4510?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15333046#comment-15333046
]
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_r67285081
--- Diff: plugins/experimental/ts_lua/ts_lua_server_response.c ---
@@ -102,11 +104,27 @@ ts_lua_server_response_get_headers(lua_State *L)
while (field_loc) {
name = TSMimeHdrFieldNameGet(http_ctx->server_response_bufp,
http_ctx->server_response_hdrp, field_loc, &name_len);
if (name && name_len) {
- value =
- TSMimeHdrFieldValueStringGet(http_ctx->server_response_bufp,
http_ctx->server_response_hdrp, field_loc, -1, &value_len);
lua_pushlstring(L, name, name_len);
- lua_pushlstring(L, value, value_len);
- lua_rawset(L, -3);
+ lua_gettable(L, -2);
+ if (lua_isnil(L, -1)) {
+ lua_pop(L, 1);
+ value =
+ TSMimeHdrFieldValueStringGet(http_ctx->server_response_bufp,
http_ctx->server_response_hdrp, field_loc, -1, &value_len);
+ lua_pushlstring(L, name, name_len);
+ lua_pushlstring(L, value, value_len);
+ lua_rawset(L, -3);
--- End diff --
Why do you ``lua_rawset`` here?
> 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)