Make Expect: 100-continue handling more robust (dotnet/corefx#24789)
authorStephen Toub <stoub@microsoft.com>
Mon, 23 Oct 2017 16:29:26 +0000 (12:29 -0400)
committerGitHub <noreply@github.com>
Mon, 23 Oct 2017 16:29:26 +0000 (12:29 -0400)
commit5a9bb53af722cbeea69b3cdfd1fbabb27c980612
tree1ed145f87284be852171cf0c0b827a8c7782516f
parentbec704cfd0635c1b05ab78a07520cdb7e3484b49
Make Expect: 100-continue handling more robust (dotnet/corefx#24789)

When libcurl sends an Expect: 100-continue header, if it gets back a success error code, it may avoid sending the remaining payload and also may keep the connection open, which can confuse servers that expect to receive the fully promised payload and that don't close the connection when sending a final success status code instead of 100 continue.  To mitigate this, we simply change the default ExpectContinue == null behavior to be the equivalent of ExpectContinue == false rather than to be "do whatever the platform decides".  This also more closely aligns with WinHttpHandler and ManagedHandler, where effectively the "platform" in those cases decides that the default is disabled.

For ManagedHandler, currently we're mimicking behavior like that libcurl employed and may sometimes not send the full payload but still keep the connection open.  Instead, make sure we either always send the full payload or close the connection.

Commit migrated from https://github.com/dotnet/corefx/commit/724ddb8fc95a5b1f639cfa508a32b9a8c50c1949
src/libraries/System.Net.Http/src/System/Net/Http/Managed/HttpConnection.cs
src/libraries/System.Net.Http/src/System/Net/Http/Unix/CurlHandler.EasyRequest.cs