Skip to content

feign.core v13.2.1 Repeatedly writing "Content-Length" #2862

@chiangzeon

Description

@chiangzeon

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:

  1. Inject a feign.RequestInterceptor instance to remove duplicate header information.
  2. Enable compression and manually calculate the request body length, but this involves modifications to other applications.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions