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

Document Content-Type header values based on the type of HttpContent used #41683

Open
simonrozsival opened this issue Jul 9, 2024 · 0 comments
Labels

Comments

@simonrozsival
Copy link
Member

Describe the issue or suggestion

This is a follow-up to a runtime issue dotnet/runtime#102923

The "Make HTTP requests with the HttpClient class" article hints that different HttpContent subclasses can be used for different mime types. I would prefer if the list would be a table and it would clearly state what the default value of the Content-Type header will be if the particular type is used.

Also, at least for the ByteArrayContent, it should mention that the content type needs to be set manually with an example such as:

var content = new ByteArrayContent(serialized);
content.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream");

Additionally, the article could mention that this behavior could vary based on the platform. For example, the Android default HTTP handler won't allow sending requests with a body but without a Content-Type header and if none is provided, it will default to application/x-www-form-urlencoded. I'm not sure if this article is an appropriate places for this mobile-specific information and if there isn't a better document that should cover it (maybe https://learn.microsoft.com/en-us/dotnet/maui/data-cloud/rest?view=net-maui-8.0 ?).

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

No branches or pull requests

2 participants