Skip to content

Commit

Permalink
Merge branch 'master' into feature/#1664_AddPaginationHandlingToRefer…
Browse files Browse the repository at this point in the history
…encesClients
  • Loading branch information
gdziadkiewicz committed Nov 11, 2017
2 parents cb90de8 + ed1feb6 commit e744502
Show file tree
Hide file tree
Showing 13 changed files with 118 additions and 5 deletions.
10 changes: 10 additions & 0 deletions Octokit.Reactive/IObservableGitHubClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,16 @@ public interface IObservableGitHubClient : IApiInfoProvider
{
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; }
Expand Down
13 changes: 13 additions & 0 deletions Octokit.Reactive/ObservableGitHubClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,19 @@ public IConnection Connection
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; }
Expand Down
15 changes: 15 additions & 0 deletions Octokit.Tests/GitHubClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -196,5 +196,20 @@ public async Task ReturnsObjectIfNotNew()
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));
}
}
}
}
13 changes: 13 additions & 0 deletions Octokit/GitHubClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,19 @@ public GitHubClient(IConnection connection)
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>
Expand Down
9 changes: 9 additions & 0 deletions Octokit/Http/Connection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -752,5 +752,14 @@ static string GetVersionInformation()

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);
}
}
}
9 changes: 9 additions & 0 deletions Octokit/Http/HttpClientAdapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,15 @@ public static async Task<HttpRequestMessage> CloneHttpRequestMessageAsync(HttpRe

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
Expand Down
6 changes: 6 additions & 0 deletions Octokit/Http/IConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -292,5 +292,11 @@ public interface IConnection : IApiInfoProvider
/// 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);
}
}
7 changes: 7 additions & 0 deletions Octokit/Http/IHttpClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,12 @@ public interface IHttpClient : IDisposable
/// <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);
}
}
10 changes: 10 additions & 0 deletions Octokit/IGitHubClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
4 changes: 2 additions & 2 deletions Octokit/Models/Response/CommitStatus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public class CommitStatus
{
public CommitStatus() { }

public CommitStatus(DateTimeOffset createdAt, DateTimeOffset updatedAt, CommitState state, string targetUrl, string description, string context, int id, string url, User creator)
public CommitStatus(DateTimeOffset createdAt, DateTimeOffset updatedAt, CommitState state, string targetUrl, string description, string context, long id, string url, User creator)
{
CreatedAt = createdAt;
UpdatedAt = updatedAt;
Expand Down Expand Up @@ -57,7 +57,7 @@ public CommitStatus(DateTimeOffset createdAt, DateTimeOffset updatedAt, CommitSt
/// <summary>
/// The unique identifier of the status.
/// </summary>
public int Id { get; protected set; }
public long Id { get; protected set; }

/// <summary>
/// The URL of the status.
Expand Down
20 changes: 20 additions & 0 deletions ReleaseNotes.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
### New in 0.28.0 (released 6/11/2017)

## Advisories and Breaking Changes

- This release has been pushed out in response to `CommitStatus.Id` on GitHub exceeding `Int32.MaxValue`. We've made this field a `long` now... sorry about that!

## Release Notes

**Features/Enhancements**

- You can now use `IGitHubClient.SetRequestTimeout(TimeSpan timeout)` to set a custom timeout, particularly useful for lengthy operations such as uploading release assets. - [#1693](https://github.com/octokit/octokit.net/pull/1693) via [@pmiossec](https://github.com/pmiossec), [@ryangribble](https://github.com/ryangribble)

**Fixes**

- Update `CommitStatus.Id` field from `int` to `long` to prevent overflow exceptions - [#1703](https://github.com/octokit/octokit.net/pull/1703) via [@kzu](https://github.com/kzu)

**Housekeeping**

- Correct rendering of `HttpClient` documentation page - [#1699](https://github.com/octokit/octokit.net/pull/1699) via [@scovetta](https://github.com/scovetta)

### New in 0.27.0 (released 7/10/2017)

## Advisories and Breaking Changes
Expand Down
4 changes: 2 additions & 2 deletions docs/http-client.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ The rules we currently follow:
- MUST use the original request's authentication credentials when following a redirect where the original host matches the redirect host.
- MUST NOT use the original request's authentication credentials when following a redirect where the original host does not match the redirect host.
- SHOULD only follow 3 redirects.
```
```

### Proxy Support

Expand Down Expand Up @@ -50,4 +50,4 @@ something you need to support: https://github.com/octokit/octokit.net/issues/809

Another request has been for auto-wiring the proxy details at runtime. Please
leave a comment in this thread if you're interested in this:
https://github.com/octokit/octokit.net/issues/594
https://github.com/octokit/octokit.net/issues/594
3 changes: 2 additions & 1 deletion docs/labels.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
Labels are appended using the method `NewIssue.Labels.Add(x)`.

Example:

var myNewIssue = new NewIssue("Issue with dropdown menu");
myNewIssue.Labels.Add("bug");

Expand All @@ -18,4 +19,4 @@ The default labels that come with every repository are:
## A Note on Label Colors
The official API returns colors without the leading `#` that you may expect when working with hex colors -- for example, white would return `FFFFFF`, not `#FFFFFF`.

If you're displaying the colors, you may need to add the `#` in order to display them properly.
If you're displaying the colors, you may need to add the `#` in order to display them properly.

0 comments on commit e744502

Please sign in to comment.