You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When sending a POST request from a Java RestClient (Spring Boot 3.2+, Java 21) to a FastAPI backend running on Uvicorn + httptools, we encountered a strange issue where the request body was missing.
Uh oh!
There was an error while loading. Please reload this page.
Overview
When sending a
POST
request from a JavaRestClient
(Spring Boot 3.2+, Java 21) to a FastAPI backend running on Uvicorn + httptools, we encountered a strange issue where the request body was missing.The request looked like this:
On the server side, Uvicorn logs showed:
Unsupported upgrade request
No request body
Invalid HTTP request received
But when we routed the same request through ngrok or used
RestTemplate
instead ofRestClient
, it worked fine.🔍 Root Cause
After analyzing Uvicorn’s
httptools_impl.py
andhttptools
parser behavior, we found this:Upgrade: h2c
is ignored by Uvicorn (as expected).httptools
still enters the upgrade state.Proposed Fix
Patch
parser.pyx
to resume HTTP/1.1 parsing after upgrade is ignored:Also expose this from Python:
Then frameworks like Uvicorn can call it in:
Reproducible Test
Why it matters
This is RFC-compliant behavior that should be supported.
RestClient in Java 21+ sends Upgrade: h2c by default.
Any server not resetting its parser state will lose the body.
This breaks many interop scenarios between Spring Boot and Python ASGI apps.
I'm happy to submit a PR if maintainers are open to it. Thanks for your time and for maintaining this great project!
The text was updated successfully, but these errors were encountered: