OpenFeign / OpenFeign/feign

GET request with empty body has Content-Length header with 0

Open
#2,085 3 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

needs info
Dominant language
Java
Stars
9.8k
Forks
1.9k
Avg merge
1d 2h
Merged PRs (30d)
41

Description

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?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the shown Feign.builder configuration with ApacheHttp5Client, using a GET request with an empty body and inspecting the emitted headers. Trace request construction in the Feign and Apache HTTP client integration; done when the request no longer emits Content-Length: 0 for this case and the behavior is covered by a regression test.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api, networking
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.