GET request with empty body has Content-Length header with 0
Nobody has claimed this yet.
- 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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