-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Description
I have two applications, A and B. B invokes A through the interface exposed by A. However, an issue occurred where A failed to decode the HTTP message on the Tomcat side, resulting in an HTTP status code of 400. Through source code analysis, I found that in the feign.Client.Default#convertAndSend
method, there is a section that adds request headers. When gzip or deflate compression of the request body is not enabled, "content-length" is written once, but it is written again later. See lines 179 to 198 of the feign.Client
class.
The feign.RequestTemplate#body(feign.Request.Body)
will calculate the length of the byte array and add it to the header. In tomcat-embed-core (v9.0.46)
, there is such a processing in org.apache.tomcat.util.http.MimeHeaders#getUniqueValue
. If the existing header information is obtained, an exception will be thrown.
My current solutions are as follows:
- Inject a feign.RequestInterceptor instance to remove duplicate header information.
- Enable compression and manually calculate the request body length, but this involves modifications to other applications.