Skip to content
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

HTTPClient.create_request should not set content type for empty bodies #425

Open
rob-spoor opened this issue Aug 11, 2020 · 0 comments
Open

Comments

@rob-spoor
Copy link

For REST APIs, it's quite common to have POST (and possibly PUT) methods that do not require a body. In method request_async2, any nil body gets transformed into an empty string. When create_request is called through do_request_async, it sets the content type to application/x-www-form-urlencoded if the body is "true" and no content type is provided. However, that should not be necessary if the body is empty.

As a workaround we now had to explicitly specify a content type (text/plain), but it would be better to simply not set a default content type if the body is empty.

Note that this is an issue that only occurs when using the async methods; the non-async methods do not transform nil bodies into empty strings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant