[Java] Jersey, Jersey2 and Resteasy clients do not support HTTP-HEAD (#6210)

This commit is contained in:
Mykola Yashchenko 2017-07-31 14:03:25 +03:00 committed by wing328
parent fab49e80a8
commit be9a9a3837
3 changed files with 9 additions and 4 deletions

View File

@ -667,8 +667,9 @@ public class ApiClient {
response = builder.type(contentType).delete(ClientResponse.class, serialize(body, contentType, formParams)); response = builder.type(contentType).delete(ClientResponse.class, serialize(body, contentType, formParams));
} else if ("PATCH".equals(method)) { } else if ("PATCH".equals(method)) {
response = builder.type(contentType).header("X-HTTP-Method-Override", "PATCH").post(ClientResponse.class, serialize(body, contentType, formParams)); response = builder.type(contentType).header("X-HTTP-Method-Override", "PATCH").post(ClientResponse.class, serialize(body, contentType, formParams));
} } else if ("HEAD".equals(method)) {
else { response = builder.head();
} else {
throw new ApiException(500, "unknown method type " + method); throw new ApiException(500, "unknown method type " + method);
} }
return response; return response;

View File

@ -636,7 +636,7 @@ public class ApiClient {
* *
* @param <T> Type * @param <T> Type
* @param path The sub-path of the HTTP URL * @param path The sub-path of the HTTP URL
* @param method The request method, one of "GET", "POST", "PUT", and "DELETE" * @param method The request method, one of "GET", "POST", "PUT", "HEAD" and "DELETE"
* @param queryParams The query parameters * @param queryParams The query parameters
* @param body The request body object * @param body The request body object
* @param headerParams The header parameters * @param headerParams The header parameters
@ -697,6 +697,8 @@ public class ApiClient {
response = invocationBuilder.delete(); response = invocationBuilder.delete();
} else if ("PATCH".equals(method)) { } else if ("PATCH".equals(method)) {
response = invocationBuilder.method("PATCH", entity); response = invocationBuilder.method("PATCH", entity);
} else if ("HEAD".equals(method)) {
response = invocationBuilder.head();
} else { } else {
throw new ApiException(500, "unknown method type " + method); throw new ApiException(500, "unknown method type " + method);
} }

View File

@ -561,7 +561,7 @@ public class ApiClient {
* Invoke API by sending HTTP request with the given options. * Invoke API by sending HTTP request with the given options.
* *
* @param path The sub-path of the HTTP URL * @param path The sub-path of the HTTP URL
* @param method The request method, one of "GET", "POST", "PUT", and "DELETE" * @param method The request method, one of "GET", "POST", "PUT", "HEAD" and "DELETE"
* @param queryParams The query parameters * @param queryParams The query parameters
* @param body The request body object * @param body The request body object
* @param headerParams The header parameters * @param headerParams The header parameters
@ -619,6 +619,8 @@ public class ApiClient {
response = invocationBuilder.delete(); response = invocationBuilder.delete();
} else if ("PATCH".equals(method)) { } else if ("PATCH".equals(method)) {
response = invocationBuilder.header("X-HTTP-Method-Override", "PATCH").post(entity); response = invocationBuilder.header("X-HTTP-Method-Override", "PATCH").post(entity);
} else if ("HEAD".equals(method)) {
response = invocationBuilder.head();
} else { } else {
throw new ApiException(500, "unknown method type " + method); throw new ApiException(500, "unknown method type " + method);
} }