MariaLapovska opened a new issue, #13015:
URL: https://github.com/apache/apisix/issues/13015

   ### Current Behavior
   
   When I modify request headers in ext-plugin-pre-req/ext-plugin-post-req and 
have ext-plugin-post-resp in the route, the header values I set in the request 
plugins are ignored and not passed to the upstream. Upstream ends up receiving 
original header values, instead of modified ones.
   
   ### Expected Behavior
   
   I expect all the request header values changed in 
ext-plugin-pre-req/ext-plugin-post-req, to be passed to upstream, no matter 
whether I have ext-plugin-post-resp called after, or not.
   
   It seems I've identified the source of the problem - it happens because 
ext-plugin-post-resp is using cached request headers when calling upstream:
   
https://github.com/apache/apisix/blob/master/apisix/plugins/ext-plugin-post-resp.lua#L39
   
   If I enforce it to pull the latest request headers by resetting the context 
(modify ext-plugin-post-resp.lua):
   ```
   local function include_req_headers(ctx)
       -- TODO: handle proxy_set_header
       ctx.headers = nil -- EDIT: enforce apisix to pull the latest headers
       return core.request.headers(ctx)
   end
   ```
   
   it works fine and the proper header values are injected when calling 
upstream.
   
   ### Error Logs
   
   _No response_
   
   ### Steps to Reproduce
   
   1. Run APISIX
   2. Create a route that would have two plugins - ext-plugin-pre-req and 
ext-plugin-post-resp
   3. Modify any of the request headers in ext-plugin-pre-req
   4. Try to make call to upstream
   5. Check what header value ends up passed to upstream
   
   ### Environment
   
   - APISIX version (run `apisix version`): 3.13.0
   - Operating system (run `uname -a`): Darwin 25.2.0
   - OpenResty / Nginx version (run `openresty -V` or `nginx -V`):
   - etcd version, if relevant (run `curl 
http://127.0.0.1:9090/v1/server_info`): 9.7.3
   - APISIX Dashboard version, if relevant: 0.8.2
   - Plugin runner version, for issues related to plugin runners: 
ext-java-plugin-runner 0.6.0
   - LuaRocks version, for installation issues (run `luarocks --version`):
   


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