runtime icon indicating copy to clipboard operation
runtime copied to clipboard

HttpClientHandler on unix (CurlHandler) Cookie Behavior different between Unix and Windows

Open kapilash opened this issue 11 years ago • 5 comments

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.

kapilash avatar Aug 29 '15 22:08 kapilash

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.

davidsh avatar Aug 31 '15 20:08 davidsh

cc: @stephentoub

davidsh avatar Aug 31 '15 20:08 davidsh

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 avatar Sep 10 '15 06:09 kapilash

@kapilash, is this still an issue or was it fixed?

stephentoub avatar Sep 22 '15 02:09 stephentoub

This has been fixed via dotnet/corefx#3178. Sorry for not updating. Closing the issue

kapilash avatar Sep 22 '15 06:09 kapilash