-
Notifications
You must be signed in to change notification settings - Fork 229
Update HttpClientSseClientTransport.java #101
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
fix: switch HttpClient to HTTP/1.1 to prevent body loss with Python servers This change modifies the HttpClient configuration to explicitly use HTTP_1_1 instead of the default HTTP_2, resolving a critical compatibility issue with Python-based servers (uvicorn/starlette) that cannot properly handle HTTP/2 upgrade requests with bodies. The issue occurs because: 1. Java's HttpClient attempts to upgrade to HTTP/2 (h2c) while simultaneously sending request bodies 2. Python servers (particularly with HttpToolsProtocol) prioritize protocol upgrade handling, causing the body parsing to be skipped or interrupted 3. This results in request bodies being lost during transmission
Hey @chaoice , thanks for highlighting this issue. You can, already, change the HttpClientSseClientTransport clientTransport = HttpClientSseClientTransport.builder(baseUri)
.clientBuilder(HttpClient.newBuilder().version(HttpClient.Version.HTTP_1_1))
.build(); I don't think we need to hardcode it as the default value. Perhaps we need to add documentation tip or warning. Do you know if this issue affects the WebFluxSseClientTransport's default configuration too? |
Thank you for your suggestion. I'd like to provide some additional context about the protocol behavior:
|
Thank you for the clarification @chaoice! I agree that we should have a consistent default HTTP client version across all MCP clients. Let me circle back on this again. |
fix: switch HttpClient to HTTP/1.1 to prevent body loss with Python servers
This change modifies the HttpClient configuration to explicitly use HTTP_1_1 instead of the default HTTP_2, resolving a critical compatibility issue with Python-based servers (uvicorn/starlette) that cannot properly handle HTTP/2 upgrade requests with bodies.
The issue occurs because:
switch HttpClient to HTTP/1.1 to prevent body loss with Python servers
Motivation and Context
Java HTTP clients sending h2c protocol upgrade requests with bodies encounter a critical issue where uvicorn (Python ASGI server) silently ignores the request body, causing data loss.

Additional context
https://github.com/microsoft/markitdown/tree/main/packages/markitdown-mcp