-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[bash] Force Content-Length: 0 on empty posts (#10462)
In the case where we are making empty posts, use -d '' to force curl to set the Content-Length header to 0. Some backends (among which Microsoft Kestrel) are sensitive about POST without a Content-Length set.
- Loading branch information
Showing
2 changed files
with
40 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
476a82c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure if this comment will be seen, but i have a problem with GET requests also having the
-d ''
set, causing Conten-Lenght: 0 and Content-Type to be set, but the Content-Type causes our API to reject the GET requests with a HTTP 415 ... is there any way to get around that?476a82c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what about adding an option to let users choose whether they want
-d ''
in the auto-generated bash script?476a82c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here is an example PR on how to add an option: #19297
we can do something similar in the bash client codegen.
would you have time to contribute the enhancement?
476a82c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi,
sure, i'd be happy to provide a PR, but i wonder if there isnt a better option, shouldnt we be able to know wether we do a GET or POST? i mean for an empty POST this might make sense but for a get we dont want to send data? Is there a way to figure out the HTTP Method we are preparing?
476a82c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks like no easy way to do it at the moment :(
I'll try to add some mustache tags (e.g. isGet, isPost) later
476a82c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as a workaround, you can use customized templates (e.g. via -t option in CLI) for the time being