-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Error in handling duplicate query parameters #56
Labels
bug
Something isn't working
Comments
@yhl-cs Nice catch! I think we just need to change these two pieces of code to
Would you like to submit a PR? 🤓 |
yhl-cs
pushed a commit
to yhl-cs/fastapi-proxy-lib
that referenced
this issue
Mar 24, 2025
Fix: WSH032#56 Signed-off-by: yhl-cs <yuhl18@zju.edu.cn>
4 tasks
yhl-cs
pushed a commit
to yhl-cs/fastapi-proxy-lib
that referenced
this issue
Mar 25, 2025
Fix: WSH032#56 Signed-off-by: yhl-cs <yuhl18@zju.edu.cn>
yhl-cs
pushed a commit
to yhl-cs/fastapi-proxy-lib
that referenced
this issue
Mar 25, 2025
Fix: WSH032#56 Signed-off-by: yhl-cs <yuhl18@zju.edu.cn>
# for free
to join this conversation on GitHub.
Already have an account?
# to comment
Describe the Bug
When sending an HTTP request with multiple query parameters of the same name (e.g.,
command=ls&command=-l&command=--full-time&command=/
), the parameters are incorrectly processed after passing through a reverse proxy.Specifically, the proxy merges or drops duplicate parameters, resulting in the backend server receiving malformed parameters (e.g., only
command=/
).This issue also affects WebSocket requests.
To Reproduce
$ python http-server.py INFO: Started server process [1097915] INFO: Waiting for application startup. INFO: Application startup complete. INFO: Uvicorn running on http://127.0.0.1:8766 (Press CTRL+C to quit)
$ python ./http-rs.py INFO: Started server process [1098305] INFO: Waiting for application startup. INFO: Application startup complete. INFO: Uvicorn running on http://0.0.0.0:8765 (Press CTRL+C to quit)
Expected Behavior
The query parameters should remain unchanged after passing through the reverse proxy. For example:
INFO: 127.0.0.1:58978 - "GET /test?stdin=false&stdout=true&stderr=true&tty=false&command=ls&command=-l&command=--full-time&command=%2F HTTP/1.1" 200 OK
Additional Context
The original request query parameters are
stdin=false&stdout=true&command=ls&command=-l&command=--full-time&command=%2F
. These are converted intostarlette.datastructures.QueryParams
1:During the initialization of
httpx.QueryParams
, the code enters theelse
branch 2. Here,value.items()
only iterates overvalue._dict
, resulting in the finalhttpx.QueryParams
data:Theoretically, it should iterate over
value._list
instead.Configuration
Footnotes
https://github.com/encode/starlette/blob/master/starlette/datastructures.py#L373 ↩
https://github.com/encode/httpx/blob/master/httpx/_urls.py#L436 ↩
The text was updated successfully, but these errors were encountered: