A simple library for parsing cookies.txt files, Netscape HTTP Cookie File format used by tools like curl and wget, into:
System.Net.CookieCollection
for use byHttpClient
IReadOnlyList<Cookie>
for inspection (since it's difficult to enumerate aCookieCollection
)
The package is available at NuGet:
dotnet add package CookiesTxtParser
Parse a file by path:
// To CookieCollection
CookiesTxt.Parser.ParseFileAsCookieCollection("/path/to/cookies.txt");
// To IReadOnlyList
CookiesTxt.Parser.ParseFileAsCookies("/path/to/cookies.txt");
Parse a stream:
// To CookieCollection
CookiesTxt.Parser.ParseStreamAsCookieCollection(stream);
// To IReadOnlyList
CookiesTxt.Parser.ParseStreamAsCookies(stream);