AlinsRan opened a new pull request, #13597:
URL: https://github.com/apache/apisix/pull/13597

   ### Description
   
   Allow `headers.set` and `headers.add` values in `proxy-rewrite` to be an 
**array**, producing multiple headers with the same name:
   
   ```json
   "proxy-rewrite": {
     "headers": {
       "set": { "X-Api-Version": ["v1", "v2"] }
     }
   }
   ```
   
   - **`set`** with an array replaces any incoming header with the listed 
values.
   - **`add`** with an array appends the listed values to the existing ones.
   - **`remove`** is unchanged (it already takes an array of names).
   
   ### Why
   
   `proxy-rewrite` models `headers.add/set` as a JSON object (map), which 
structurally cannot express same-name multi-value headers — a JSON object can't 
hold two values for one key. This is a real gap vs. other gateways that model 
header transforms as an ordered list of (name, value) pairs (Kong 
`request-transformer` `append.headers`, Envoy `request_headers_to_add`, HAProxy 
`add-header`). The array form closes it. Genuine use cases: gRPC metadata 
(repeated keys → repeated HTTP/2 headers) and backends/auth proxies that read 
repeated custom headers.
   
   Fully backward compatible: existing string/number values keep working; the 
array is an additive schema option. Each element still supports NGINX variables 
and `regex_uri` captures.
   
   This also gives the clean answer to the `remove + add` ordering confusion in 
#11587 — multi-value is a data-model feature, not an operation-order one.
   
   ### Which issue(s) this PR fixes
   
   Closes #13163
   
   ### Changes
   
   - `apisix/plugins/proxy-rewrite.lua`: schema allows `array<string|number>` 
for `add`/`set` values; apply loop resolves each element (`set` → one 
`set_header` with a table; `add` → one `add_header` per element).
   - `t/plugin/proxy-rewrite.t`: tests for `set` (replace with multiple) and 
`add` (append multiple); `t/lib/server.lua`: echo helper joining same-name 
headers.
   - `docs/{en,zh}/.../proxy-rewrite.md`: attribute docs + example.
   
   ### Checklist
   
   - [x] I have explained the need for this PR and the problem it solves
   - [x] I have explained the changes or the new features added to this PR
   - [x] I have added tests corresponding to this change
   - [x] I have updated the documentation to reflect this change
   - [x] I have verified that this change is backward compatible (if not, 
please discuss on the [APISIX mailing 
list](https://github.com/apache/apisix/blob/master/CONTRIBUTING.md#submit-a-proposal)
 first)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to