-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Remove Content-Type Header when request with empty body POST method #2555
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove Content-Type Header when request with empty body POST method #2555
Conversation
30079f9
to
21ed9eb
Compare
This look good. Could you please add some information to the README to indicate how to take advantage of this change, helping folks understand the System Property requirement? |
5757b3d
to
49d5f4d
Compare
@kdavisk6 sure, I added it. |
8b27da5
to
0f759bf
Compare
…Default Client). - add Content-Length Header with 0 value when `sun.net.http.allowRestrictedHeaders` System Property is set true - fix not running test to run - add README for setting zero content-length header
5be2434
to
e2fbea1
Compare
@velo
|
Hello, good morning, how are you today? Raise a PR with test case. Thank you. |
Hi @velo, this PR turned out into a breaking change for us, currently we have some POST requests sent with no body, for example: @PostMapping("/action/{actionId}")
String performAction(@PathVariable Long actionId); it fails when the request goes through our gateway proxy which forces us to either send the request with an empty body
We cannot use |
Hi.
I have looked this issue and got an idea to deal with.
In current code, convert null body to not null and it write to outputstream.
In that process, when writing empty string in outputstream, unwanted Content-Type Header is added which is ''application/x-www-form-urlencoded".
So, I rearrange null body code to avoid unwanted header.
With this, Content-Length header is not set, so I added. But, this header is restricted header so 'sun.net.http.allowRestrictedHeaders' system property should be true to add content-length header.
And this property should be set before client class loaded. I guess there is no suitable way to inject restricted header to connection.
Feel Free to comment this idea. thanks.