Commit 133623a0 authored by Greg Messner's avatar Greg Messner
Browse files

Fixed PUT with no entity (#101).

parent 0e33be2d
...@@ -403,7 +403,12 @@ public class GitLabApiClient { ...@@ -403,7 +403,12 @@ public class GitLabApiClient {
* @return a ClientResponse instance with the data returned from the endpoint * @return a ClientResponse instance with the data returned from the endpoint
*/ */
protected Response put(MultivaluedMap<String, String> queryParams, URL url) { protected Response put(MultivaluedMap<String, String> queryParams, URL url) {
return (invocation(url, null).put(Entity.entity(queryParams, MediaType.APPLICATION_FORM_URLENCODED_TYPE))); if (queryParams == null || queryParams.isEmpty()) {
Entity<?> empty = Entity.text("");
return (invocation(url, null).put(empty));
} else {
return (invocation(url, null).put(Entity.entity(queryParams, MediaType.APPLICATION_FORM_URLENCODED_TYPE)));
}
} }
/** /**
......
...@@ -112,8 +112,7 @@ public class RepositoryApi extends AbstractApi { ...@@ -112,8 +112,7 @@ public class RepositoryApi extends AbstractApi {
/** /**
* Delete a single project repository branch. This is an idempotent function, * Delete a single project repository branch.
* protecting an already protected repository branch will not produce an error.
* *
* DELETE /projects/:id/repository/branches/:branch * DELETE /projects/:id/repository/branches/:branch
* *
...@@ -138,7 +137,7 @@ public class RepositoryApi extends AbstractApi { ...@@ -138,7 +137,7 @@ public class RepositoryApi extends AbstractApi {
* @throws GitLabApiException if any exception occurs * @throws GitLabApiException if any exception occurs
*/ */
public Branch protectBranch(Integer projectId, String branchName) throws GitLabApiException { public Branch protectBranch(Integer projectId, String branchName) throws GitLabApiException {
Response response = put(Response.Status.OK, null, "projects", projectId, "repository", "branches", branchName, "protect"); Response response = put(Response.Status.OK, null, "projects", projectId, "repository", "branches", urlEncode(branchName), "protect");
return (response.readEntity(Branch.class)); return (response.readEntity(Branch.class));
} }
...@@ -154,7 +153,7 @@ public class RepositoryApi extends AbstractApi { ...@@ -154,7 +153,7 @@ public class RepositoryApi extends AbstractApi {
* @throws GitLabApiException if any exception occurs * @throws GitLabApiException if any exception occurs
*/ */
public Branch unprotectBranch(Integer projectId, String branchName) throws GitLabApiException { public Branch unprotectBranch(Integer projectId, String branchName) throws GitLabApiException {
Response response = put(Response.Status.OK, null, "projects", projectId, "repository", "branches", branchName, "unprotect"); Response response = put(Response.Status.OK, null, "projects", projectId, "repository", "branches", urlEncode(branchName), "unprotect");
return (response.readEntity(Branch.class)); return (response.readEntity(Branch.class));
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment