Document Content-Type header values based on the type of HttpContent used
- Dominant language
- No language data
- Stars
- 4.8k
- Forks
- 6.1k
- Avg merge
- 15h 21m
- Merged PRs (30d)
- 370
Description
### Describe the issue or suggestion
This is a follow-up to a runtime issue https://github.com/dotnet/runtime/issues/102923
The ["Make HTTP requests with the HttpClient class" article](https://learn.microsoft.com/en-us/dotnet/fundamentals/networking/http/httpclient#http-content) 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:
```c#
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 ?).
Contributor guide
Assessment
This issue has not been assessed yet.