Skip to content

Commit

Permalink
Merge pull request #23 from AngleSharp/devel
Browse files Browse the repository at this point in the history
Release 0.13.1
  • Loading branch information
FlorianRappl authored Sep 24, 2019
2 parents b426803 + 5f6c77c commit c26cbce
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 5 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# 0.13.1

Released on Tuesday, September 24 2019.

- Ignore non-existing cookie file when reading
- Write cookies after every add operation

# 0.13.0

Released on Friday, September 6 2019.
Expand Down
2 changes: 1 addition & 1 deletion src/AngleSharp.Io/Cookie/AdvancedCookieProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ public void AddCookie(WebCookie cookie)
{
_cookies.Remove(FindCookie(cookie.Domain, cookie.Path, cookie.Key));
InsertCookie(cookie);
WriteCookies();
}
}

Expand Down Expand Up @@ -251,7 +252,6 @@ private void InsertCookie(WebCookie cookie)
}

_cookies.Add(cookie);
WriteCookies();
}

private void WriteCookies()
Expand Down
3 changes: 2 additions & 1 deletion src/AngleSharp.Io/Cookie/LocalFileHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ public class LocalFileHandler : ICookieFileHandler
/// <param name="filePath">The path to resolve to.</param>
public LocalFileHandler(String filePath) => _filePath = filePath;

String ICookieFileHandler.ReadFile() => File.ReadAllText(_filePath);
String ICookieFileHandler.ReadFile() => File.Exists(_filePath) ?
File.ReadAllText(_filePath) : String.Empty;

void ICookieFileHandler.WriteFile(String content)
{
Expand Down
19 changes: 17 additions & 2 deletions src/AngleSharp.Io/IoConfigurationExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,29 @@ public static IConfiguration WithStandardDownload(this IConfiguration configurat
/// <param name="configuration">The configuration to use.</param>
/// <returns>The new configuration.</returns>
public static IConfiguration WithRequesters(this IConfiguration configuration) =>
configuration.WithRequesters(new HttpClientHandler { UseCookies = false, AllowAutoRedirect = false });
configuration.WithRequesters(new HttpClientHandler());

/// <summary>
/// Adds the requesters from the AngleSharp.Io package.
/// </summary>
/// <param name="configuration">The configuration to use.</param>
/// <param name="httpClientHandler">
/// The HTTP client handler to use for sending requests.
/// </param>
/// <returns>The new configuration.</returns>
public static IConfiguration WithRequesters(this IConfiguration configuration, HttpClientHandler httpClientHandler)
{
httpClientHandler.UseCookies = false;
httpClientHandler.AllowAutoRedirect = false;
return configuration.WithRequesters((HttpMessageHandler)httpClientHandler);
}

/// <summary>
/// Adds the requesters from the AngleSharp.Io package.
/// </summary>
/// <param name="configuration">The configuration to use.</param>
/// <param name="httpMessageHandler">
/// The HTTP handler stack to use for sending requests.
/// The HTTP message handler to use for sending requests.
/// </param>
/// <returns>The new configuration.</returns>
public static IConfiguration WithRequesters(this IConfiguration configuration, HttpMessageHandler httpMessageHandler)
Expand Down
2 changes: 1 addition & 1 deletion src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
<PropertyGroup>
<Description>Providers additional requesters and IO helpers for AngleSharp.</Description>
<Product>AngleSharp.Io</Product>
<Version>0.13.0</Version>
<Version>0.13.1</Version>
</PropertyGroup>
</Project>

0 comments on commit c26cbce

Please sign in to comment.