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

PUT requests will not send a json payload regardless of content type #1306

Open
gamebox opened this issue Sep 19, 2024 · 0 comments
Open

PUT requests will not send a json payload regardless of content type #1306

gamebox opened this issue Sep 19, 2024 · 0 comments
Labels
package:http type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)

Comments

@gamebox
Copy link

gamebox commented Sep 19, 2024

When I use http.put() and supply a JSON encoded string as the body or a utf8 encoded series of bytes representing the same string as the bodyBytes, the body will not be sent with the request regardless of me specifying the content type as either

final headers = <String, String>{
  'Content-Type': 'application/json',
};

or

final headers = <String, String>{
  'Content-Type': 'application/json; charset=UTF-8',
};

The content type will be there, but the body is just not sent. The exact same body and headers will send the body when using http.post.

My question is: Is this intended behavior?

The server I am communicating with is under my control so I can change the method(will not do that as I am obviously PUTting data in this use case), and I can also switch it to use x-www-url-encoded (my temporary workaround), but there is no standards-based reason for JSON not to be sent with a PUT.

If additional context is needed, I am happy to help out some old friends, and please tell me if there is something I'm missing or getting wrong. :-)

@gamebox gamebox added package:http type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) labels Sep 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
package:http type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
None yet
Development

No branches or pull requests

1 participant