Feign sets content-length header to 0 when GET request has no body

321 Views Asked by At

I am using the following code to make a request to an endpoint fronted with an ALB.

Feign.builder()
        .logger(Slf4jLogger(MyApi::class.java))
        .logLevel(feign.Logger.Level.FULL)
        .encoder(JacksonEncoder(objectMapper))
        .decoder(JacksonDecoder(objectMapper))
        .requestInterceptor { template -> template.header("X-Api-Key", apiKey) }
        .client(ApacheHttp5Client())
        .target(Target.HardCodedTarget(MyApi::class.java, apiUrl))

I am using the client to send GET requests to my endpoint /api/service/account/xxxx with an empty request body. In the receiving end, I am noticing that there is a header Content-Length with value 0, which makes the request non-compliant with rfc7230. I am using feign 12.3 and httpclient5 5.2.1. How can I get rid of this unwanted header?

0

There are 0 best solutions below