Open goxiaoy opened 2 years ago
local len = rewrite:RespHeadersLength()
if len > 0 then
for i = 1, len do
local entry = rewrite:RespHeaders(i)
local name = entry:Name()
if exclude_resp_header[str_lower(name)] == nil then
core.response.set_header(name, entry:Value())
end
end
end
Codes here should take multiple header with same name into account
@rampagecong @shuaijinchao
Very good idea. I'll give it a try.
Very good idea. I'll give it a try.
Currently in Runner, headers are stored using map, which does not support repeated header settings, which may require us to extend the header key. If you have better ideas, you can always reply here.
cc @Goxiaoy
Origin servers SHOULD NOT fold multiple Set-Cookie header fields into a single header field. The usual mechanism for folding HTTP headers fields (i.e., as defined in [RFC2616]) might change the semantics of the Set-Cookie header field because the %x2C (",") character is used by Set-Cookie in a way that conflicts with such folding.
So it is a common use case for set multiple header with same name like Set-Cookie
For the Runner,
RespHeader is defined as standard golang net/http
header, which is a map of array of string
type Header map[string][]string
And later header is serialized into HeadersVector, https://github.com/apache/apisix-go-plugin-runner/blob/dee7fa0167af0ed8cdcd87d4321a43b194f2a7ed/internal/http/request.go#L253-L272
So I do not think it is a bug of Runner
For the APISIX ext-plugin
local len = rewrite:RespHeadersLength()
if len > 0 then
for i = 1, len do
local entry = rewrite:RespHeaders(i)
local name = entry:Name()
if exclude_resp_header[str_lower(name)] == nil then
- core.response.set_header(name, entry:Value())
+ core.response.add_header(name, entry:Value())
end
end
end
Might fix this bug Should I open a new issue in APISIX?
@shuaijinchao I've tested the code above and it worked. But I'm not sure if core.response.add_header
will break anything else. Could you please take a look?
@shuaijinchao I've tested the code above and it worked. But I'm not sure if
core.response.add_header
will break anything else. Could you please take a look?
You are right, after verification I found no abnormality, @spacewander what do you think?
The add_header
won't override the existent header. What about using a table to track headers, using set_header
first and using add_header
if the same header occurs again?
The
add_header
won't override the existent header. What about using a table to track headers, usingset_header
first and usingadd_header
if the same header occurs again? I think it works.I'll try to fix it.
The problem still exists, not solved
@jthann upgrade apisix to 2.14.0 or newer
Issue description
Cookie
a
is missing in the response headerEnvironment
uname -a
): centosMinimal test code / Steps to reproduce the issue