Closed as not planned
Closed as not planned
Description
Spring HTTP Client Issues with HTTP/1.0 Server Integration
Issue Summary
Spring HTTP clients (WebClient, RestClient, RestTemplate) fail to properly receive data from the server, while the same requests work fine with HttpURLConnection, OpenFeign, and OkHttp3. Intermittent "Connection reset" exceptions occur during response reading.
Server Response Analysis (via Wireshark)
- Server responds with HTTP/1.0
- Response headers include "Connection: close" , "Content-Type: application/json"
Steps to Reproduce
- Send HTTP request using Spring's HTTP clients (WebClient or RestTemplate)
- Server responds with HTTP/1.0 and "Connection: close", "Content-Type: application/json"
- While reading the response, connection is reset intermittently
We're experiencing two distinct issues while integrating with a legacy HTTP/1.0 server that we cannot modify:
- Content-Length Header Problem
- Intermittent Connection Resets
Issue 1: Missing Content-Length Header
Problem Statement
- Server operates on HTTP/1.0 protocol requiring mandatory Content-Length header
- Spring HTTP clients are not including this header automatically
- StringHttpMessageConverter works (includes Content-Length)
- MappingJackson2HttpMessageConverter fails (missing Content-Length)
- Results in server rejections or improper request handling
Current Behavior
- Requests fail without Content-Length header
- Only working with StringHttpMessageConverter
- Other converters failing consistently
- Direct impact on request reliability
Issue 2: Intermittent Connection Reset
Problem Statement
- Random connection resets during response processing
- Specific to HTTP/1.0 responses with "Connection: close" header
- Only occurs with Spring HTTP clients
- Alternative clients work fine (HttpURLConnection, OpenFeign, OkHttp3)
Current Behavior
- Unpredictable connection drops
- Data loss during response reading
- Failed requests requiring retry
- Inconsistent response handling
Environment
- Spring Framework: 6.2.1
- Java: 21
- Third-party Server Protocol: HTTP/1.0
- Response Headers: Connection: close, Content-Type: application/json
Questions
- Is there a recommended configuration for handling HTTP/1.0 servers with mandatory Content-Length?
- How can we properly handle the "Connection: close" behavior in Spring HTTP clients?
- Are there known workarounds for these issues in Spring Framework?
- Would using alternative message converters or custom implementations help?
Additional Information
- Server configuration cannot be modified