HttpClientHandler on unix (CurlHandler) Cookie Behavior different between Unix and Windows
There are subtle differences in the way HttpClientHandler behaves w.r.t cookies. On windows if we set httpHandler.UseCookies = true but if the user does not provide a valid cookieContainer, we get InvalidOperationException. In case of CurlHandler, we are ignoring it.
The Windows version of HttpClient is such that the default for the CookieContainer property should return a non-null empty container. It should not return null as the default.
Here is the ToF test for the constructor defaults:
[TestMethod] public void Ctor_VerifyDefaults_Success() { var handler = new HttpClientHandler(); Assert.AreEqual(ClientCertificateOption.Manual, handler.ClientCertificateOptions); Assert.IsTrue(handler.UseCookies); Assert.IsNotNull(handler.CookieContainer); Assert.AreEqual(0, handler.CookieContainer.Count); }
You should make sure that the Linus version is the same. This particular ToF test is in the process of being ported to the HttpClientHandlerTest.cs file.
cc: @stephentoub
Reopening the same issue as there are further inconsistencies in the behavior:
There are the following differences between CurlHandler and WinhttpHandler:
- Cookies coming from the server aren't handled properly.
- In case of redirect, curl handler needs to set the appropriate cookies based on the redirect URI.
@kapilash, is this still an issue or was it fixed?
This has been fixed via dotnet/corefx#3178. Sorry for not updating. Closing the issue