/** * Convenience method to invoke the request using <code>GET</code> method and receive a response entity payload * of {@link List} type back. * @param <T> Response entity type * @param responseType Expected {@link List} response type * @return the response payload of expected type as the result of the request invocation, or an empty List if * not present * @throws HttpClientInvocationException Internal invocation failure (for example, an I/O error on communication * channel or expected and actual payload type mismatch) * @throws UnsuccessfulResponseException In case the status code of the response returned by the server is not a * successful type status code, i.e. it is not a <code>2xx</code> status code */ @Override default <T> List<T> getAsList(Class<T> responseType) { final ResponseType<List<T>> rt = ResponseType.of(responseType, List.class); return getForEntity(rt).orElse(Collections.emptyList()); }
/** * Invoke the request using <code>GET</code> method and receive the response entity {@link InputStream} back. * @return the response payload {@link InputStream}, or an empty stream for empty responses * @throws HttpClientInvocationException Internal invocation failure (for example, an I/O error on communication * channel or expected and actual payload type mismatch) * @throws UnsuccessfulResponseException In case the status code of the response returned by the server is not a * successful type status code, i.e. it is not a <code>2xx</code> status code */ @Override default InputStream getForStream() { return invokeForEntity(HttpMethod.GET, null, ResponseType.of(InputStream.class)) .orElse(new ByteArrayInputStream(new byte[0])); }
/** * Invoke the request using <code>PATCH</code> method with given <code>entity</code> request payload and receive * the response entity payload back. * @param <T> Response entity type * @param entity Request payload * @param responseType Expected response payload type * @return the response payload of expected type as the result of the request invocation, or an empty Optional * if not present (empty response entity) * @throws HttpClientInvocationException Internal invocation failure (for example, an I/O error on communication * channel or expected and actual payload type mismatch) * @throws UnsuccessfulResponseException In case the status code of the response returned by the server is not a * successful type status code, i.e. it is not a <code>2xx</code> status code */ @Override default <T> Optional<T> patchForEntity(RequestEntity<?> entity, ResponseType<T> responseType) { return invokeForEntity(HttpMethod.PATCH, entity, responseType); }
/** * Invoke the request using <code>PUT</code> method with given <code>entity</code> request entity payload and * receive the response payload back. * @param <T> Response entity type * @param entity Request payload * @param responseType Expected response payload type * @return the response payload of expected type as the result of the request invocation, or an empty Optional * if not present (empty response entity) * @throws HttpClientInvocationException Internal invocation failure (for example, an I/O error on communication * channel or expected and actual payload type mismatch) * @throws UnsuccessfulResponseException In case the status code of the response returned by the server is not a * successful type status code, i.e. it is not a <code>2xx</code> status code */ @Override default <T> Optional<T> putForEntity(RequestEntity<?> entity, ResponseType<T> responseType) { return invokeForEntity(HttpMethod.PUT, entity, responseType); }
/** * Invoke the request using <code>PUT</code> method with given <code>entity</code> request payload and receive * the response entity payload back. * @param <T> Response entity type * @param entity Request payload * @param responseType Expected response payload type * @return the response payload of expected type as the result of the request invocation, or an empty Optional * if not present (empty response entity) * @throws HttpClientInvocationException Internal invocation failure (for example, an I/O error on communication * channel or expected and actual payload type mismatch) * @throws UnsuccessfulResponseException In case the status code of the response returned by the server is not a * successful type status code, i.e. it is not a <code>2xx</code> status code */ @Override default <T> Optional<T> putForEntity(RequestEntity<?> entity, Class<T> responseType) { return invokeForEntity(HttpMethod.PUT, entity, ResponseType.of(responseType)); }
/** * Invoke the request using <code>POST</code> method with given <code>entity</code> request payload and receive * the response payload back. * @param <T> Response type * @param entity Request payload * @param responseType Expected response payload type * @return the response payload of expected type as the result of the request invocation, or an empty Optional * if not present (empty response entity) * @throws HttpClientInvocationException Internal invocation failure (for example, an I/O error on communication * channel or expected and actual payload type mismatch) * @throws UnsuccessfulResponseException In case the status code of the response returned by the server is not a * successful type status code, i.e. it is not a <code>2xx</code> status code */ @Override default <T> Optional<T> postForEntity(RequestEntity<?> entity, Class<T> responseType) { return invokeForEntity(HttpMethod.POST, entity, ResponseType.of(responseType)); }
/** * Invoke the request using <code>PATCH</code> method with given <code>entity</code> request payload and receive * a response back. * @param <T> Response type * @param entity Request payload * @param responseType Expected response payload type * @return {@link ResponseEntity} object as a result of the request invocation * @throws HttpClientInvocationException Internal invocation failure (for example, an I/O error on communication * channel or expected and actual payload type mismatch) * @throws UnsuccessfulResponseException In case the status code of the response returned by the server is not a * successful type status code, i.e. it is not a <code>2xx</code> status code */ @Override default <T> ResponseEntity<T> patch(RequestEntity<?> entity, ResponseType<T> responseType) { return invoke(HttpMethod.PATCH, entity, responseType); }
/** * Invoke the request using <code>PATCH</code> method with given <code>entity</code> request payload and receive * a response back. * <p> * The response type is conventionally of {@link Void} type, because no response paylod is expected from this * invocation. Refer to the other <code>post</code> methods to obtain a response payload. * </p> * @param entity Request payload * @return {@link ResponseEntity} object as a result of the request invocation * @throws HttpClientInvocationException Internal invocation failure (for example, an I/O error on communication * channel or expected and actual payload type mismatch) */ @Override default ResponseEntity<Void> patch(RequestEntity<?> entity) { return invoke(HttpMethod.PATCH, entity, ResponseType.of(Void.class)); }
/** * Invoke the request using <code>POST</code> method with given <code>entity</code> request payload and receive * a response back. * <p> * The response type is conventionally of {@link Void} type, because no response paylod is expected from this * invocation. Refer to the other <code>post</code> methods to obtain a response payload. * </p> * @param entity Request payload * @return {@link ResponseEntity} object as a result of the request invocation * @throws HttpClientInvocationException Internal invocation failure (for example, an I/O error on communication * channel or expected and actual payload type mismatch) */ @Override default ResponseEntity<Void> post(RequestEntity<?> entity) { return invoke(HttpMethod.POST, entity, ResponseType.of(Void.class)); }
/** * Invoke the request using <code>DELETE</code> method and receive the response entity payload of given generic * type back. * @param <T> Response entity type * @param responseType Response payload generic type representation * @return the response payload of expected type as the result of the request invocation, or an empty Optional * if not present (empty response entity) * @throws HttpClientInvocationException Internal invocation failure (for example, an I/O error on communication * channel or expected and actual payload type mismatch) * @throws UnsuccessfulResponseException In case the status code of the response returned by the server is not a * successful type status code, i.e. it is not a <code>2xx</code> status code */ @Override default <T> Optional<T> deleteForEntity(ResponseType<T> responseType) { return invokeForEntity(HttpMethod.DELETE, null, responseType); }
/** * Invoke the request using <code>OPTIONS</code> method and receive the response entity payload of given generic * type back. * @param <T> Response entity type * @param responseType Response payload generic type representation * @return the response payload of expected type as the result of the request invocation, or an empty Optional * if not present (empty response entity) * @throws HttpClientInvocationException Internal invocation failure (for example, an I/O error on communication * channel or expected and actual payload type mismatch) * @throws UnsuccessfulResponseException In case the status code of the response returned by the server is not a * successful type status code, i.e. it is not a <code>2xx</code> status code */ @Override default <T> Optional<T> optionsForEntity(ResponseType<T> responseType) { return invokeForEntity(HttpMethod.OPTIONS, null, responseType); }
/** * Invoke the request using <code>PATCH</code> method with given <code>entity</code> request payload and receive * a response back. * @param <T> Response type * @param entity Request payload * @param responseType Expected response payload type * @return {@link ResponseEntity} object as a result of the request invocation * @throws HttpClientInvocationException Internal invocation failure (for example, an I/O error on communication * channel or expected and actual payload type mismatch) * @throws UnsuccessfulResponseException In case the status code of the response returned by the server is not a * successful type status code, i.e. it is not a <code>2xx</code> status code */ @Override default <T> ResponseEntity<T> patch(RequestEntity<?> entity, Class<T> responseType) { return invoke(HttpMethod.PATCH, entity, ResponseType.of(responseType)); }
/** * Invoke the request using <code>PATCH</code> method with given <code>entity</code> request payload and receive * the response entity payload back. * @param <T> Response entity type * @param entity Request payload * @param responseType Expected response payload type * @return the response payload of expected type as the result of the request invocation, or an empty Optional * if not present (empty response entity) * @throws HttpClientInvocationException Internal invocation failure (for example, an I/O error on communication * channel or expected and actual payload type mismatch) * @throws UnsuccessfulResponseException In case the status code of the response returned by the server is not a * successful type status code, i.e. it is not a <code>2xx</code> status code */ @Override default <T> Optional<T> patchForEntity(RequestEntity<?> entity, Class<T> responseType) { return invokeForEntity(HttpMethod.PATCH, entity, ResponseType.of(responseType)); }
/** * Invoke the request using <code>OPTIONS</code> method and receive the response entity payload back. * @param <T> Response entity type * @param responseType Expected response payload type * @return the response payload of expected type as the result of the request invocation, or an empty Optional * if not present (empty response entity) * @throws HttpClientInvocationException Internal invocation failure (for example, an I/O error on communication * channel or expected and actual payload type mismatch) * @throws UnsuccessfulResponseException In case the status code of the response returned by the server is not a * successful type status code, i.e. it is not a <code>2xx</code> status code */ @Override default <T> Optional<T> optionsForEntity(Class<T> responseType) { return invokeForEntity(HttpMethod.OPTIONS, null, ResponseType.of(responseType)); }
/** * Invoke the request using <code>POST</code> method with given <code>entity</code> request payload and receive * the response payload back. * @param <T> Response type * @param entity Request payload * @param responseType Expected response payload type * @return the response payload of expected type as the result of the request invocation, or an empty Optional * if not present (empty response entity) * @throws HttpClientInvocationException Internal invocation failure (for example, an I/O error on communication * channel or expected and actual payload type mismatch) * @throws UnsuccessfulResponseException In case the status code of the response returned by the server is not a * successful type status code, i.e. it is not a <code>2xx</code> status code */ @Override default <T> Optional<T> postForEntity(RequestEntity<?> entity, ResponseType<T> responseType) { return invokeForEntity(HttpMethod.POST, entity, responseType); }
/** * Invoke the request using <code>PUT</code> method with given <code>entity</code> request payload and receive a * response back. * @param <T> Response type * @param entity Request payload * @param responseType Expected response payload type * @return {@link ResponseEntity} object as a result of the request invocation * @throws HttpClientInvocationException Internal invocation failure (for example, an I/O error on communication * channel or expected and actual payload type mismatch) */ @Override default <T> ResponseEntity<T> put(RequestEntity<?> entity, ResponseType<T> responseType) { return invoke(HttpMethod.PUT, entity, responseType); }
/** * Invoke the request using <code>POST</code> method with given <code>entity</code> request payload and receive * a response back. * @param <T> Response type * @param entity Request payload * @param responseType Expected response payload type * @return {@link ResponseEntity} object as a result of the request invocation * @throws HttpClientInvocationException Internal invocation failure (for example, an I/O error on communication * channel or expected and actual payload type mismatch) */ @Override default <T> ResponseEntity<T> post(RequestEntity<?> entity, Class<T> responseType) { return invoke(HttpMethod.POST, entity, ResponseType.of(responseType)); }
/** * Invoke the request using <code>PUT</code> method with given <code>entity</code> request payload and receive a * response back. * <p> * The response type is conventionally of {@link Void} type, because no response paylod is expected from this * invocation. Refer to the other <code>post</code> methods to obtain a response payload. * </p> * @param entity Request payload * @return {@link ResponseEntity} object as a result of the request invocation * @throws HttpClientInvocationException Internal invocation failure (for example, an I/O error on communication * channel or expected and actual payload type mismatch) */ @Override default ResponseEntity<Void> put(RequestEntity<?> entity) { return invoke(HttpMethod.PUT, entity, ResponseType.of(Void.class)); }
/** * Invoke the request using <code>TRACE</code> method and receive a response back. * <p> * The response type is conventionally of {@link Void} type, because no response paylod is expected from this * invocation. Refer to the other <code>post</code> methods to obtain a response payload. * </p> * @return {@link ResponseEntity} object as a result of the request invocation * @throws HttpClientInvocationException Internal invocation failure (for example, an I/O error on communication * channel or expected and actual payload type mismatch) */ @Override default ResponseEntity<Void> trace() { return invoke(HttpMethod.TRACE, null, ResponseType.of(Void.class)); }
/** * Invoke the request using <code>PUT</code> method with given <code>entity</code> request payload and receive a * response back. * @param <T> Response type * @param entity Request payload * @param responseType Expected response payload type * @return {@link ResponseEntity} object as a result of the request invocation * @throws HttpClientInvocationException Internal invocation failure (for example, an I/O error on communication * channel or expected and actual payload type mismatch) */ @Override default <T> ResponseEntity<T> put(RequestEntity<?> entity, Class<T> responseType) { return invoke(HttpMethod.PUT, entity, ResponseType.of(responseType)); }