Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a method to set HttpClient timeout #51

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions FeedReader/FeedReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
using Parser;
Expand All @@ -21,6 +22,16 @@
/// </example>
public static class FeedReader
{
#if NETSTANDARD1_1_OR_GREATER || NETCOREAPP1_0_OR_GREATER || NET45_OR_GREATER
/// <summary>
/// Set a timeout for reading feeds
/// </summary>
public static void SetTimeout(TimeSpan timeout)
{
Helpers.SetTimeout(timeout);
}
#endif

/// <summary>
/// gets a url (with or without http) and returns the full url
/// </summary>
Expand Down
7 changes: 7 additions & 0 deletions FeedReader/Helpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@ public static class Helpers
}
);

#if NETSTANDARD1_1_OR_GREATER || NETCOREAPP1_0_OR_GREATER || NET45_OR_GREATER
internal static void SetTimeout(TimeSpan timeout)
{
_httpClient.Timeout = timeout;
}
#endif

/// <summary>
/// Download the content from an url
/// </summary>
Expand Down