Revert "[System] Don't assume WebConnectionStream of unknown http methods require write stream. Fixes #31830"
This reverts commit
8ccfe0f8ff71d18151f8aad90d0855dfd2d2a723.
This commit breaks the Content-Type logic for existing HTTP verbs such as for instance
using DELETE with an empty body [1]. Added two new test cases [2] and [3] to the stable
branch of the web-tests (https://github.com/xamarin/web-tests/tree/stable) for the particular
scenario from bug #31830 as well as the default HttpClient.SendAsync() without a Content [4].
The rules are as follows:
1.) HttpWebRequest adds the Content-Length header if and only if you're calling
GetRequestStream(); a length of 0 will be used if you don't actually write
any content.
This is true for POST, PUT, DELETE and "obscute" verbs.
2.) HttpClient.SendAsync() always adds a Content-Length header.
Tests:
[1] https://github.com/xamarin/web-tests/blob/
31b8fed0ec1283b8c0693bb14d1ac266792c1020/Xamarin.WebTests/Xamarin.WebTests.Tests/TestPost.cs#L84
[2] https://github.com/xamarin/web-tests/blob/
31b8fed0ec1283b8c0693bb14d1ac266792c1020/Xamarin.WebTests/Xamarin.WebTests.Tests/TestPost.cs#L296
[3] https://github.com/xamarin/web-tests/blob/
31b8fed0ec1283b8c0693bb14d1ac266792c1020/Xamarin.WebTests/Xamarin.WebTests.Tests/TestHttpClient.cs#L134
[4] https://github.com/xamarin/web-tests/blob/
31b8fed0ec1283b8c0693bb14d1ac266792c1020/Xamarin.WebTests/Xamarin.WebTests.Tests/TestHttpClient.cs#L127
(cherry picked from commit
3f1ae72f1b385c3c5e4b5ac2b93d13418c020f02)