Skip to content

[Cookie] HttpClient does not properly parse all Set-Cookie headers #20942

@Nothing4You

Description

@Nothing4You

Hello,

I'm currently trying to build a .Net Core application that automates some HTTP requests.
In the first request I receive several cookies which should be sent back to the server on the second request.
For demonstration purposes I have created a small PHP script that sends some Set-Cookie headers similar to the style I receive them from the actual application.
The source code of this script is https://gist.github.com/Nothing4You/6623cda16eb2c2c5b4d3d9106b95a6ce. You can find a live version at https://hosting.rep.pm/cookietest.php.
I have tested the script using a web browser (Firefox), curl (in a linux shell) aswell as using python requests, which all handle cookies and show me the expected output in the second request:

Cookie[test1]: test1value
Cookie[test2]: test=2&value=2
Cookie[test3]: $test-3
Cookie[test4]: test4

However, if I try to do the same thing using System.Net.Http.HttpClient it only sets the 2 out of 4 cookies.

According to Visual Studio I'm using SDK version 1.1.1.
HttpClient is the following version:

Assembly: System.Net.Http, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
Assembly location: .nuget\packages\system.net.http\4.3.0\ref\netstandard1.3\System.Net.Http.dll

Example code: https://gist.github.com/Nothing4You/c04af6781f8520efb4921ef144733731

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions