mirror of
https://github.com/zoriya/octokit.net.git
synced 2026-06-06 03:55:55 +00:00
Add cancellation token support for release assets uploading (#2267)
This commit is contained in:
+30
-16
@@ -251,44 +251,51 @@ namespace Octokit
|
||||
/// Performs an asynchronous HTTP POST request.
|
||||
/// </summary>
|
||||
/// <param name="uri">URI endpoint to send request to</param>
|
||||
/// <param name="cancellationToken">An optional token to monitor for cancellation requests</param>
|
||||
/// <returns><seealso cref="IResponse"/> representing the received HTTP response</returns>
|
||||
public async Task<HttpStatusCode> Post(Uri uri)
|
||||
public async Task<HttpStatusCode> Post(Uri uri, CancellationToken cancellationToken = default)
|
||||
{
|
||||
Ensure.ArgumentNotNull(uri, nameof(uri));
|
||||
|
||||
var response = await SendData<object>(uri, HttpMethod.Post, null, null, null, CancellationToken.None).ConfigureAwait(false);
|
||||
var response = await SendData<object>(uri, HttpMethod.Post, null, null, null, cancellationToken).ConfigureAwait(false);
|
||||
return response.HttpResponse.StatusCode;
|
||||
}
|
||||
|
||||
public async Task<HttpStatusCode> Post(Uri uri, object body, string accepts)
|
||||
public async Task<HttpStatusCode> Post(Uri uri, object body, string accepts, CancellationToken cancellationToken = default)
|
||||
{
|
||||
Ensure.ArgumentNotNull(uri, nameof(uri));
|
||||
|
||||
var response = await SendData<object>(uri, HttpMethod.Post, body, accepts, null, CancellationToken.None).ConfigureAwait(false);
|
||||
var response = await SendData<object>(uri, HttpMethod.Post, body, accepts, null, cancellationToken).ConfigureAwait(false);
|
||||
return response.HttpResponse.StatusCode;
|
||||
}
|
||||
|
||||
public Task<IApiResponse<T>> Post<T>(Uri uri)
|
||||
public Task<IApiResponse<T>> Post<T>(Uri uri, CancellationToken cancellationToken = default)
|
||||
{
|
||||
Ensure.ArgumentNotNull(uri, nameof(uri));
|
||||
|
||||
return SendData<T>(uri, HttpMethod.Post, null, null, null, CancellationToken.None);
|
||||
return SendData<T>(uri, HttpMethod.Post, null, null, null, cancellationToken);
|
||||
}
|
||||
|
||||
public Task<IApiResponse<T>> Post<T>(Uri uri, object body, string accepts, string contentType)
|
||||
public Task<IApiResponse<T>> Post<T>(Uri uri, object body, string accepts, string contentType, CancellationToken cancellationToken = default)
|
||||
{
|
||||
Ensure.ArgumentNotNull(uri, nameof(uri));
|
||||
Ensure.ArgumentNotNull(body, nameof(body));
|
||||
|
||||
return SendData<T>(uri, HttpMethod.Post, body, accepts, contentType, CancellationToken.None);
|
||||
return SendData<T>(uri, HttpMethod.Post, body, accepts, contentType, cancellationToken);
|
||||
}
|
||||
|
||||
public Task<IApiResponse<T>> Post<T>(Uri uri, object body, string accepts, string contentType, IDictionary<string, string> parameters)
|
||||
public Task<IApiResponse<T>> Post<T>(
|
||||
Uri uri,
|
||||
object body,
|
||||
string accepts,
|
||||
string contentType,
|
||||
IDictionary<string, string> parameters,
|
||||
CancellationToken cancellationToken = default)
|
||||
{
|
||||
Ensure.ArgumentNotNull(uri, nameof(uri));
|
||||
Ensure.ArgumentNotNull(body, nameof(body));
|
||||
|
||||
return SendData<T>(uri.ApplyParameters(parameters), HttpMethod.Post, body, accepts, contentType, CancellationToken.None);
|
||||
return SendData<T>(uri.ApplyParameters(parameters), HttpMethod.Post, body, accepts, contentType, cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -301,30 +308,37 @@ namespace Octokit
|
||||
/// <param name="accepts">Specifies accepted response media types.</param>
|
||||
/// <param name="contentType">Specifies the media type of the request body</param>
|
||||
/// <param name="twoFactorAuthenticationCode">Two Factor Authentication Code</param>
|
||||
/// <param name="cancellationToken">An optional token to monitor for cancellation requests</param>
|
||||
/// <returns><seealso cref="IResponse"/> representing the received HTTP response</returns>
|
||||
public Task<IApiResponse<T>> Post<T>(Uri uri, object body, string accepts, string contentType, string twoFactorAuthenticationCode)
|
||||
public Task<IApiResponse<T>> Post<T>(
|
||||
Uri uri,
|
||||
object body,
|
||||
string accepts,
|
||||
string contentType,
|
||||
string twoFactorAuthenticationCode,
|
||||
CancellationToken cancellationToken = default)
|
||||
{
|
||||
Ensure.ArgumentNotNull(uri, nameof(uri));
|
||||
Ensure.ArgumentNotNull(body, nameof(body));
|
||||
Ensure.ArgumentNotNullOrEmptyString(twoFactorAuthenticationCode, nameof(twoFactorAuthenticationCode));
|
||||
|
||||
return SendData<T>(uri, HttpMethod.Post, body, accepts, contentType, CancellationToken.None, twoFactorAuthenticationCode);
|
||||
return SendData<T>(uri, HttpMethod.Post, body, accepts, contentType, cancellationToken, twoFactorAuthenticationCode);
|
||||
}
|
||||
|
||||
public Task<IApiResponse<T>> Post<T>(Uri uri, object body, string accepts, string contentType, TimeSpan timeout)
|
||||
public Task<IApiResponse<T>> Post<T>(Uri uri, object body, string accepts, string contentType, TimeSpan timeout, CancellationToken cancellationToken = default)
|
||||
{
|
||||
Ensure.ArgumentNotNull(uri, nameof(uri));
|
||||
Ensure.ArgumentNotNull(body, nameof(body));
|
||||
|
||||
return SendData<T>(uri, HttpMethod.Post, body, accepts, contentType, timeout, CancellationToken.None);
|
||||
return SendData<T>(uri, HttpMethod.Post, body, accepts, contentType, timeout, cancellationToken);
|
||||
}
|
||||
|
||||
public Task<IApiResponse<T>> Post<T>(Uri uri, object body, string accepts, string contentType, Uri baseAddress)
|
||||
public Task<IApiResponse<T>> Post<T>(Uri uri, object body, string accepts, string contentType, Uri baseAddress, CancellationToken cancellationToken = default)
|
||||
{
|
||||
Ensure.ArgumentNotNull(uri, nameof(uri));
|
||||
Ensure.ArgumentNotNull(body, nameof(body));
|
||||
|
||||
return SendData<T>(uri, HttpMethod.Post, body, accepts, contentType, CancellationToken.None, baseAddress: baseAddress);
|
||||
return SendData<T>(uri, HttpMethod.Post, body, accepts, contentType, cancellationToken, baseAddress: baseAddress);
|
||||
}
|
||||
|
||||
public Task<IApiResponse<T>> Put<T>(Uri uri, object body)
|
||||
|
||||
Reference in New Issue
Block a user