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

Bugfix/#2870 expecting media type when deleting file #2878

Open
wants to merge 4 commits into
base: main
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
3 changes: 2 additions & 1 deletion Octokit/Clients/RepositoryContentsClient.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Net.Mime;
using System.Threading.Tasks;

namespace Octokit
Expand Down Expand Up @@ -523,7 +524,7 @@ public Task DeleteFile(long repositoryId, string path, DeleteFileRequest request
Ensure.ArgumentNotNull(request, nameof(request));

var deleteUrl = ApiUrls.RepositoryContent(repositoryId, path);
return ApiConnection.Delete(deleteUrl, request);
return ApiConnection.Delete(deleteUrl, request, "", "application/json"); // TODO MediaTypeNames.Application.Json);
}
}
}
19 changes: 19 additions & 0 deletions Octokit/Http/ApiConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,8 @@ public Task Delete(Uri uri, object data)

return Connection.Delete(uri, data);
}



/// <summary>
/// Performs an asynchronous HTTP DELETE request that expects an empty response.
Expand All @@ -567,6 +569,23 @@ public Task Delete(Uri uri, object data, string accepts)
return Connection.Delete(uri, data, accepts);
}

/// <summary>
/// Performs an asynchronous HTTP DELETE request that expects an empty response.
/// </summary>
/// <param name="uri">URI endpoint to send request to</param>
/// <param name="data">The object to serialize as the body of the request</param>
/// <param name="accepts">Specifies accept response media type</param>
/// <param name="contentType">Specifies body request media type</param>
/// <returns>The returned <seealso cref="HttpStatusCode"/></returns>
public Task Delete(Uri uri, object data, string accepts, string contentType)
{
Ensure.ArgumentNotNull(uri, nameof(uri));
Ensure.ArgumentNotNull(data, nameof(data));
Ensure.ArgumentNotNull(accepts, nameof(accepts));

return Connection.Delete(uri, data, accepts,contentType);
}

/// <summary>
/// Performs an asynchronous HTTP DELETE request.
/// </summary>
Expand Down
12 changes: 11 additions & 1 deletion Octokit/Http/Connection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,8 @@ public async Task<HttpStatusCode> Delete(Uri uri, object data)
Method = HttpMethod.Delete,
Body = data,
BaseAddress = BaseAddress,
Endpoint = uri
Endpoint = uri,
ContentType = "application/json"
};
var response = await Run<object>(request, CancellationToken.None).ConfigureAwait(false);
return response.HttpResponse.StatusCode;
Expand All @@ -617,6 +618,15 @@ public async Task<HttpStatusCode> Delete(Uri uri, object data, string accepts)
var response = await SendData<object>(uri, HttpMethod.Delete, data, accepts, null, CancellationToken.None).ConfigureAwait(false);
return response.HttpResponse.StatusCode;
}

public async Task<HttpStatusCode> Delete(Uri uri, object data, string accepts, string contentType)
{
Ensure.ArgumentNotNull(uri, nameof(uri));
Ensure.ArgumentNotNull(accepts, nameof(accepts));

var response = await SendData<object>(uri, HttpMethod.Delete, data, accepts, contentType, CancellationToken.None).ConfigureAwait(false);
return response.HttpResponse.StatusCode;
}

/// <summary>
/// Performs an asynchronous HTTP DELETE request.
Expand Down
10 changes: 10 additions & 0 deletions Octokit/Http/IApiConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,16 @@ public interface IApiConnection
/// <returns>The returned <seealso cref="HttpStatusCode"/></returns>
Task Delete(Uri uri, object data, string accepts);

/// <summary>
/// Performs an asynchronous HTTP DELETE request that expects an empty response.
/// </summary>
/// <param name="uri">URI endpoint to send request to</param>
/// <param name="data">The object to serialize as the body of the request</param>
/// <param name="accepts">Specifies accept response media type</param>
/// <param name="contentType">Specifies body request media type</param>
/// <returns>The returned <seealso cref="HttpStatusCode"/></returns>
Task Delete(Uri uri, object data, string accepts, string contentType);

/// <summary>
/// Performs an asynchronous HTTP DELETE request.
/// </summary>
Expand Down
2 changes: 2 additions & 0 deletions Octokit/Http/IConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,8 @@ Task<IApiResponse<T>> Post<T>(
/// <param name="accepts">Specifies accept response media type</param>
Task<IApiResponse<T>> Delete<T>(Uri uri, object data, string accepts);

Task<HttpStatusCode> Delete(Uri uri, object data, string accepts, string contentType);

/// <summary>
/// Base address for the connection.
/// </summary>
Expand Down
Loading