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

   ### Description
   
   With `apisix.normalize_uri_like_servlet: true`, every proxied request loses 
its query string: the upstream receives the path only.
   
   `_M.http_access_phase()` sets `$upstream_uri` to the original path so that 
servlet upstreams still see the parameters after `;`:
   
   ```lua
   api_ctx.var.upstream_uri = core.utils.uri_safe_encode(uri)
   ```
   
   `uri` is `ngx.var.uri`, which never carries the query string. Assigning 
`$upstream_uri` at all is what causes the loss: with the variable left empty, 
`proxy_pass $upstream_scheme://apisix_backend$upstream_uri` falls back to 
forwarding the client's request line verbatim, query string included. A 
non-empty value turns that fallback off, and nothing puts the query string back.
   
   This PR re-appends `$is_args$args` to the forwarded path, the same way 
`proxy-rewrite` already does when it rewrites the path itself, so the two paths 
that set `$upstream_uri` now produce the same shape. That also fixes 
`proxy-mirror`, which treats a non-empty `$upstream_uri` as already containing 
the query string.
   
   An encoded question mark stays percent-encoded in the forwarded path, as 
before — `uri_safe_encode()` escapes `?`, so the appended `?` is the only 
unencoded one.
   
   #### Which issue(s) this PR fixes:
   
   N/A
   
   ### 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
   - [ ] I have updated the documentation to reflect this change
   - [x] I have verified that this change is backward compatible
   
   Documentation is unchanged: the query string reaching the upstream is the 
behavior the option was always meant to have and is not described anywhere as 
being dropped, so there is nothing to correct in `docs/`.
   
   Tests: `t/router/servlet-upstream-uri.t` gains a case asserting the upstream 
sees both the servlet parameters and the query string. It fails on `master` 
(upstream receives `/anything/sub;jsessionid=x`, query gone) and passes with 
this change. The existing case covering `%3F` staying percent-encoded is 
unaffected.
   


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