question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

feign.httpclient.ApacheHttpClient should not setEntity when request body is null in order to support application/x-www-form-urlencode

See original GitHub issue

In recently, I replaced “com.netflix.feign:feign-httpclient:8.18.0” with “io.github.openfeign:feign-httpclient” along with spring boot application, because which from netflix is deprecated.

I found a difference between two dependencies that one from netflix let entity null on building request, the other from openfeign(this repo.) let entity be an empty byte array.

So, org.apache.http.client.methods.RequestBuilder comes to finally build a HttpUriRequest of InternalRequest skipping making entityCopy be UrlEncodedFormEntity, even if headers has ‘Content-Type: application/x-www-form-urlencoded’.

So I finally got 400 Bad Request from other spring cloud server.

I think, as a wrapper of apache http client, feign.httpclient should follow apache’s implementation.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
kdavisk6commented, Dec 27, 2019

From what I can tell looking into this, the issue lies with our use of the RequestBuilder, which explicitly states:

Please note that this class treats parameters differently depending on composition of the request: if the request has a content entity explicitly set with setEntity(org.apache.http.HttpEntity) or it is not an entity enclosing method (such as POST or PUT), parameters will be added to the query component of the request URI. Otherwise, parameters will be added as a URL encoded entity.

Since you appear to be one of a few with this issue, I suspect the issue is in your implementation. Can you please provide a test case the replicates your issue?

0reactions
starrybleucommented, May 29, 2019

I found it has conflict with #510, #511. But after failed to test, dug into the RequestBuilder. Test of withoutBody should be done along without @PUT or @POST.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Feign Client Get Request HttpStatus 200 but body is null when ...
I have an issue with my Feign client, I get the response as well when the json not containing lot of data. But...
Read more >
Intro to Feign | Baeldung
In this tutorial, we'll introduce Feign — a declarative HTTP client developed by Netflix. Feign aims at simplifying HTTP API clients.
Read more >
feign.httpclient.ApacheHttpClient Maven ... - Download JAR files
ApacheHttpClient maven / gradle build tool code. The class is part of the package ➦ Group: io.github.openfeign ➦ Artifact: feign-httpclient ➦ Version: 9.7.0....
Read more >
Apache HttpClient HTTP PUT Request with JSON Body
How to send PUT request with JSON using Apache HttpClient? In this tutorial, we will test the 'Dummy Sample Rest API' which is...
Read more >
How to configure fiegn clients to perform HTTP requests in ...
Next, let us call the feign client and see how the request body will look like on the target service. localServiceClient.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found