SouthwestAsiaFloat opened a new issue, #6360:
URL: https://github.com/apache/shenyu/issues/6360

   ### Is there an existing issue for this?
   
   - [x] I have searched the existing issues
   
   ### Current Behavior
   
   In the Request plugin, `addParameters`, `addHeaders`, and `addCookies` 
behave the same as their corresponding `set*` operations when the target key 
already exists.
   
   For example, when the original request contains:
   
   ```text
   ?tag=old
   ```
   
   and the Request plugin is configured with:
   
   ```json
   {
     "parameter": {
       "addParameters": {
         "tag": "new"
       }
     }
   }
   ```
   
   the downstream service receives:
   
   ```text
   tag=new
   ```
   
   instead of preserving the original value.
   
   The current implementation routes both `add*` and `set*` operations through 
the same logic based on `set()`, resulting in identical behavior.
   
   ### Expected Behavior
   
   `add*` operations should preserve existing values and append the configured 
value, while `set*` operations should continue to overwrite existing values.
   
   Example:
   
   ```text
   Original request:
   ?tag=old
   
   addParameters(tag=new)
   ```
   
   Expected:
   
   ```text
   tag=old&tag=new
   ```
   
   or an equivalent multi-value representation.
   
   The same semantic distinction should apply to headers and cookies.
   
   ### Steps To Reproduce
   
   1. Enable the Request plugin.
   
   2. Configure a Request plugin rule:
   
   ```json
   {
     "parameter": {
       "addParameters": {
         "tag": "new"
       }
     }
   }
   ```
   
   3. Send a request containing an existing query parameter:
   
   ```bash
   curl "http://localhost:9195/http/request-bug/echo?tag=old";
   ```
   
   4. Observe that the downstream service receives:
   
   ```text
   tag=new
   ```
   
   instead of preserving the original value and appending the new value.
   
   ### Environment
   
   ```markdown
   ShenYu version: 2.4.0
   Apache ShenYu master branch
   Module: shenyu-plugin-request
   Local standalone deployment
   ```
   
   ### Debug logs
   
   RequestHandle documents addHeaders as "need to be appended new header value",
   while setHeaders is documented as covering/overwriting the value.
   
   ModifyResponsePlugin also implements:
   
   addHeaders -> HttpHeaders.add(...)
   setHeaders -> HttpHeaders.set(...)
   
   which suggests that add and set are intended to have different semantics.
   
   
   
   ### Anything else?
   
   I would be happy to work on a PR if this behavior is confirmed as a bug😄.


-- 
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