Revert "[System] Don't assume WebConnectionStream of unknown http methods require...
authorMartin Baulig <martin.baulig@xamarin.com>
Tue, 28 Jul 2015 17:06:08 +0000 (19:06 +0200)
committerMartin Baulig <martin.baulig@xamarin.com>
Tue, 28 Jul 2015 19:14:03 +0000 (21:14 +0200)
commitbf1e02d4d49da6255679c046ffa404fe48f92687
treec89ead8ce4cac9e53dbd7bbb7bfa8317cc7f93e5
parent355ecbfe9803909cc08b6830319312b4934d363d
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)
mcs/class/System/System.Net/WebConnectionStream.cs