mirror of
https://github.com/zoriya/octokit.net.git
synced 2026-06-01 02:18:44 +00:00
* Add possibility to configure GitHubClient timeout (#963) A first attempt to fix the problem describe in #963 by adding a possibility to extend the default timeout value (100s) that is too short to be able to post assets in github release. * Rename to SetRequestTimeout Make comments consistent
This commit is contained in:
committed by
Ryan Gribble
parent
2495487608
commit
c8ff57b24c
@@ -6,6 +6,16 @@ namespace Octokit.Reactive
|
||||
{
|
||||
IConnection Connection { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Set the GitHub Api request timeout.
|
||||
/// Useful to set a specific timeout for lengthy operations, such as uploading release assets
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See more information here: https://technet.microsoft.com/library/system.net.http.httpclient.timeout(v=vs.110).aspx
|
||||
/// </remarks>
|
||||
/// <param name="timeout">The Timeout value</param>
|
||||
void SetRequestTimeout(TimeSpan timeout);
|
||||
|
||||
IObservableAuthorizationsClient Authorization { get; }
|
||||
IObservableActivitiesClient Activity { get; }
|
||||
IObservableIssuesClient Issue { get; }
|
||||
|
||||
@@ -54,6 +54,20 @@ namespace Octokit.Reactive
|
||||
get { return _gitHubClient.Connection; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set the GitHub Api request timeout.
|
||||
/// Useful to set a specific timeout for lengthy operations, such as uploading release assets
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See more information here: https://technet.microsoft.com/library/system.net.http.httpclient.timeout(v=vs.110).aspx
|
||||
/// </remarks>
|
||||
/// <param name="timeout">The Timeout value</param>
|
||||
public void SetRequestTimeout(TimeSpan timeout)
|
||||
{
|
||||
|
||||
_gitHubClient.SetRequestTimeout(timeout);
|
||||
}
|
||||
|
||||
public IObservableAuthorizationsClient Authorization { get; private set; }
|
||||
public IObservableActivitiesClient Activity { get; private set; }
|
||||
public IObservableIssuesClient Issue { get; private set; }
|
||||
|
||||
@@ -196,5 +196,20 @@ namespace Octokit.Tests
|
||||
var temp = connection.Received(1).GetLastApiInfo();
|
||||
}
|
||||
}
|
||||
|
||||
public class TheSetRequestTimeoutMethod
|
||||
{
|
||||
[Fact]
|
||||
public void SetsTheTimeoutOnTheUnderlyingHttpClient()
|
||||
{
|
||||
var httpClient = Substitute.For<IHttpClient>();
|
||||
var client = new GitHubClient(new Connection(new ProductHeaderValue("OctokitTests"), httpClient));
|
||||
|
||||
client.SetRequestTimeout(TimeSpan.FromSeconds(15));
|
||||
|
||||
|
||||
httpClient.Received(1).SetRequestTimeout(TimeSpan.FromSeconds(15));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -99,6 +99,19 @@ namespace Octokit
|
||||
Reaction = new ReactionsClient(apiConnection);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set the GitHub Api request timeout.
|
||||
/// Useful to set a specific timeout for lengthy operations, such as uploading release assets
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See more information here: https://technet.microsoft.com/library/system.net.http.httpclient.timeout(v=vs.110).aspx
|
||||
/// </remarks>
|
||||
/// <param name="timeout">The Timeout value</param>
|
||||
public void SetRequestTimeout(TimeSpan timeout)
|
||||
{
|
||||
Connection.SetRequestTimeout(timeout);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the latest API Info - this will be null if no API calls have been made
|
||||
/// </summary>
|
||||
|
||||
@@ -752,5 +752,14 @@ namespace Octokit
|
||||
|
||||
return _versionInformation;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set the GitHub Api request timeout.
|
||||
/// </summary>
|
||||
/// <param name="timeout">The Timeout value</param>
|
||||
public void SetRequestTimeout(TimeSpan timeout)
|
||||
{
|
||||
_httpClient.SetRequestTimeout(timeout);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -264,6 +264,15 @@ namespace Octokit.Internal
|
||||
|
||||
return newRequest;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set the GitHub Api request timeout.
|
||||
/// </summary>
|
||||
/// <param name="timeout">The Timeout value</param>
|
||||
public void SetRequestTimeout(TimeSpan timeout)
|
||||
{
|
||||
_http.Timeout = timeout;
|
||||
}
|
||||
}
|
||||
|
||||
internal class RedirectHandler : DelegatingHandler
|
||||
|
||||
@@ -292,5 +292,11 @@ namespace Octokit
|
||||
/// the default <see cref="InMemoryCredentialStore"/> with just these credentials.
|
||||
/// </remarks>
|
||||
Credentials Credentials { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Set the GitHub Api request timeout.
|
||||
/// </summary>
|
||||
/// <param name="timeout">The Timeout value</param>
|
||||
void SetRequestTimeout(TimeSpan timeout);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,5 +19,12 @@ namespace Octokit.Internal
|
||||
/// <param name="cancellationToken">Used to cancel the request</param>
|
||||
/// <returns>A <see cref="Task" /> of <see cref="IResponse"/></returns>
|
||||
Task<IResponse> Send(IRequest request, CancellationToken cancellationToken);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Set the GitHub Api request timeout.
|
||||
/// </summary>
|
||||
/// <param name="timeout">The Timeout value</param>
|
||||
void SetRequestTimeout(TimeSpan timeout);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,16 @@ namespace Octokit
|
||||
/// </summary>
|
||||
public interface IGitHubClient : IApiInfoProvider
|
||||
{
|
||||
/// <summary>
|
||||
/// Set the GitHub Api request timeout.
|
||||
/// Useful to set a specific timeout for lengthy operations, such as uploading release assets
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See more information here: https://technet.microsoft.com/library/system.net.http.httpclient.timeout(v=vs.110).aspx
|
||||
/// </remarks>
|
||||
/// <param name="timeout">The Timeout value</param>
|
||||
void SetRequestTimeout(TimeSpan timeout);
|
||||
|
||||
/// <summary>
|
||||
/// Provides a client connection to make rest requests to HTTP endpoints.
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user