/** * Invoke the request using <code>OPTIONS</code> method and receive a response back. * @param <T> Response type * @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> options(Class<T> responseType) { return invoke(HttpMethod.OPTIONS, null, ResponseType.of(responseType)); }
/** * Invoke the request using <code>DELETE</code> method and receive a response back. * @param <T> Response type * @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> delete(Class<T> responseType) { return invoke(HttpMethod.DELETE, null, ResponseType.of(responseType)); }
/** * Invoke the request using <code>TRACE</code> method and receive a response back. * @param <T> Response type * @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> trace(Class<T> responseType) { return invoke(HttpMethod.TRACE, null, ResponseType.of(responseType)); }
/** * Invoke the request using <code>HEAD</code> method and receive a response back. * @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> head() { return invoke(HttpMethod.HEAD, null, ResponseType.of(Void.class)); }
/** * Invoke the request using <code>GET</code> method and receive a response back. * @param <T> Response type * @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> get(Class<T> responseType) { return invoke(HttpMethod.GET, null, ResponseType.of(responseType)); }
/** * Invoke the request using <code>DELETE</code> method. If the returned response is not a <em>success</em> * response (i.e. with a <code>2xx</code> status code), a {@link UnsuccessfulResponseException} is thrown. * @throws HttpClientInvocationException Internal invocation failure (for example, an I/O error on communication * channel) * @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 */ default void deleteOrFail() { invokeForSuccess(HttpMethod.DELETE, null, ResponseType.of(Void.class)); }
/** * Invoke the request using <code>DELETE</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) */ @Override default ResponseEntity<Void> delete() { return invoke(HttpMethod.DELETE, null, ResponseType.of(Void.class)); }
/** * Invoke the request using <code>OPTIONS</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) */ @Override default ResponseEntity<Void> options() { return invoke(HttpMethod.OPTIONS, null, ResponseType.of(Void.class)); }
/** * 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>GET</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> getForEntity(Class<T> responseType) { return invokeForEntity(HttpMethod.GET, null, ResponseType.of(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, Class<T> responseType) { return invoke(HttpMethod.PUT, entity, ResponseType.of(responseType)); }
/** * 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>DELETE</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> deleteForEntity(Class<T> responseType) { return invokeForEntity(HttpMethod.DELETE, null, ResponseType.of(responseType)); }
/** * Invoke the request using <code>TRACE</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> traceForEntity(Class<T> responseType) { return invokeForEntity(HttpMethod.TRACE, null, ResponseType.of(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)); }
@Override public <E> Flux<E> asFlux(Class<E> entityType) { final ResponseType<List<E>> rt = ResponseType.of(entityType, List.class); return as(rt).map(r -> Flux.fromIterable(r)).orElse(Flux.empty()); }
/** * Invoke the request using <code>POST</code> method with given <code>entity</code> request payload and receive * the value of the <code>LOCATION</code> header back, if present. * @param entity Request payload * @return the value of the <code>LOCATION</code> header back, if 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 Optional<URI> postForLocation(RequestEntity<?> entity) { return invokeForSuccess(HttpMethod.POST, entity, ResponseType.of(Void.class)).getLocation(); }