|
|
|
|
@ -1,5 +1,5 @@
@@ -1,5 +1,5 @@
|
|
|
|
|
/* |
|
|
|
|
* Copyright 2002-2021 the original author or authors. |
|
|
|
|
* Copyright 2002-2024 the original author or authors. |
|
|
|
|
* |
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
|
@ -30,7 +30,8 @@ import org.springframework.lang.Nullable;
@@ -30,7 +30,8 @@ import org.springframework.lang.Nullable;
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Interface specifying a basic set of RESTful operations. |
|
|
|
|
* Implemented by {@link RestTemplate}. Not often used directly, but a useful |
|
|
|
|
* |
|
|
|
|
* <p>Implemented by {@link RestTemplate}. Not often used directly, but a useful |
|
|
|
|
* option to enhance testability, as it can easily be mocked or stubbed. |
|
|
|
|
* |
|
|
|
|
* @author Arjen Poutsma |
|
|
|
|
@ -67,7 +68,7 @@ public interface RestOperations {
@@ -67,7 +68,7 @@ public interface RestOperations {
|
|
|
|
|
<T> T getForObject(String url, Class<T> responseType, Map<String, ?> uriVariables) throws RestClientException; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Retrieve a representation by doing a GET on the URL . |
|
|
|
|
* Retrieve a representation by doing a GET on the URL. |
|
|
|
|
* The response (if any) is converted and returned. |
|
|
|
|
* @param url the URL |
|
|
|
|
* @param responseType the type of the return value |
|
|
|
|
@ -78,7 +79,7 @@ public interface RestOperations {
@@ -78,7 +79,7 @@ public interface RestOperations {
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Retrieve an entity by doing a GET on the specified URL. |
|
|
|
|
* The response is converted and stored in an {@link ResponseEntity}. |
|
|
|
|
* The response is converted and stored in a {@link ResponseEntity}. |
|
|
|
|
* <p>URI Template variables are expanded using the given URI variables, if any. |
|
|
|
|
* @param url the URL |
|
|
|
|
* @param responseType the type of the return value |
|
|
|
|
@ -91,7 +92,7 @@ public interface RestOperations {
@@ -91,7 +92,7 @@ public interface RestOperations {
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Retrieve a representation by doing a GET on the URI template. |
|
|
|
|
* The response is converted and stored in an {@link ResponseEntity}. |
|
|
|
|
* The response is converted and stored in a {@link ResponseEntity}. |
|
|
|
|
* <p>URI Template variables are expanded using the given map. |
|
|
|
|
* @param url the URL |
|
|
|
|
* @param responseType the type of the return value |
|
|
|
|
@ -103,8 +104,8 @@ public interface RestOperations {
@@ -103,8 +104,8 @@ public interface RestOperations {
|
|
|
|
|
throws RestClientException; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Retrieve a representation by doing a GET on the URL . |
|
|
|
|
* The response is converted and stored in an {@link ResponseEntity}. |
|
|
|
|
* Retrieve a representation by doing a GET on the URL. |
|
|
|
|
* The response is converted and stored in a {@link ResponseEntity}. |
|
|
|
|
* @param url the URL |
|
|
|
|
* @param responseType the type of the return value |
|
|
|
|
* @return the converted object |
|
|
|
|
@ -144,7 +145,7 @@ public interface RestOperations {
@@ -144,7 +145,7 @@ public interface RestOperations {
|
|
|
|
|
// POST
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Create a new resource by POSTing the given object to the URI template, and returns the value of |
|
|
|
|
* Create a new resource by POSTing the given object to the URI template, and return the value of |
|
|
|
|
* the {@code Location} header. This header typically indicates where the new resource is stored. |
|
|
|
|
* <p>URI Template variables are expanded using the given URI variables, if any. |
|
|
|
|
* <p>The {@code request} parameter can be a {@link HttpEntity} in order to |
|
|
|
|
@ -164,7 +165,7 @@ public interface RestOperations {
@@ -164,7 +165,7 @@ public interface RestOperations {
|
|
|
|
|
URI postForLocation(String url, @Nullable Object request, Object... uriVariables) throws RestClientException; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Create a new resource by POSTing the given object to the URI template, and returns the value of |
|
|
|
|
* Create a new resource by POSTing the given object to the URI template, and return the value of |
|
|
|
|
* the {@code Location} header. This header typically indicates where the new resource is stored. |
|
|
|
|
* <p>URI Template variables are expanded using the given map. |
|
|
|
|
* <p>The {@code request} parameter can be a {@link HttpEntity} in order to |
|
|
|
|
@ -185,7 +186,7 @@ public interface RestOperations {
@@ -185,7 +186,7 @@ public interface RestOperations {
|
|
|
|
|
throws RestClientException; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Create a new resource by POSTing the given object to the URL, and returns the value of the |
|
|
|
|
* Create a new resource by POSTing the given object to the URL, and return the value of the |
|
|
|
|
* {@code Location} header. This header typically indicates where the new resource is stored. |
|
|
|
|
* <p>The {@code request} parameter can be a {@link HttpEntity} in order to |
|
|
|
|
* add additional HTTP headers to the request. |
|
|
|
|
@ -204,7 +205,7 @@ public interface RestOperations {
@@ -204,7 +205,7 @@ public interface RestOperations {
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Create a new resource by POSTing the given object to the URI template, |
|
|
|
|
* and returns the representation found in the response. |
|
|
|
|
* and return the representation found in the response. |
|
|
|
|
* <p>URI Template variables are expanded using the given URI variables, if any. |
|
|
|
|
* <p>The {@code request} parameter can be a {@link HttpEntity} in order to |
|
|
|
|
* add additional HTTP headers to the request. |
|
|
|
|
@ -226,7 +227,7 @@ public interface RestOperations {
@@ -226,7 +227,7 @@ public interface RestOperations {
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Create a new resource by POSTing the given object to the URI template, |
|
|
|
|
* and returns the representation found in the response. |
|
|
|
|
* and return the representation found in the response. |
|
|
|
|
* <p>URI Template variables are expanded using the given map. |
|
|
|
|
* <p>The {@code request} parameter can be a {@link HttpEntity} in order to |
|
|
|
|
* add additional HTTP headers to the request. |
|
|
|
|
@ -248,7 +249,7 @@ public interface RestOperations {
@@ -248,7 +249,7 @@ public interface RestOperations {
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Create a new resource by POSTing the given object to the URL, |
|
|
|
|
* and returns the representation found in the response. |
|
|
|
|
* and return the representation found in the response. |
|
|
|
|
* <p>The {@code request} parameter can be a {@link HttpEntity} in order to |
|
|
|
|
* add additional HTTP headers to the request. |
|
|
|
|
* <p>The body of the entity, or {@code request} itself, can be a |
|
|
|
|
@ -267,7 +268,7 @@ public interface RestOperations {
@@ -267,7 +268,7 @@ public interface RestOperations {
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Create a new resource by POSTing the given object to the URI template, |
|
|
|
|
* and returns the response as {@link ResponseEntity}. |
|
|
|
|
* and return the response as {@link ResponseEntity}. |
|
|
|
|
* <p>URI Template variables are expanded using the given URI variables, if any. |
|
|
|
|
* <p>The {@code request} parameter can be a {@link HttpEntity} in order to |
|
|
|
|
* add additional HTTP headers to the request. |
|
|
|
|
@ -288,7 +289,7 @@ public interface RestOperations {
@@ -288,7 +289,7 @@ public interface RestOperations {
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Create a new resource by POSTing the given object to the URI template, |
|
|
|
|
* and returns the response as {@link HttpEntity}. |
|
|
|
|
* and return the response as {@link HttpEntity}. |
|
|
|
|
* <p>URI Template variables are expanded using the given map. |
|
|
|
|
* <p>The {@code request} parameter can be a {@link HttpEntity} in order to |
|
|
|
|
* add additional HTTP headers to the request. |
|
|
|
|
@ -309,7 +310,7 @@ public interface RestOperations {
@@ -309,7 +310,7 @@ public interface RestOperations {
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Create a new resource by POSTing the given object to the URL, |
|
|
|
|
* and returns the response as {@link ResponseEntity}. |
|
|
|
|
* and return the response as {@link ResponseEntity}. |
|
|
|
|
* <p>The {@code request} parameter can be a {@link HttpEntity} in order to |
|
|
|
|
* add additional HTTP headers to the request. |
|
|
|
|
* <p>The body of the entity, or {@code request} itself, can be a |
|
|
|
|
@ -373,7 +374,7 @@ public interface RestOperations {
@@ -373,7 +374,7 @@ public interface RestOperations {
|
|
|
|
|
* <p>The {@code request} parameter can be a {@link HttpEntity} in order to |
|
|
|
|
* add additional HTTP headers to the request. |
|
|
|
|
* <p><b>NOTE: The standard JDK HTTP library does not support HTTP PATCH. |
|
|
|
|
* You need to use the Apache HttpComponents or OkHttp request factory.</b> |
|
|
|
|
* You need to use e.g. the Apache HttpComponents request factory.</b> |
|
|
|
|
* @param url the URL |
|
|
|
|
* @param request the object to be PATCHed (may be {@code null}) |
|
|
|
|
* @param responseType the type of the return value |
|
|
|
|
@ -382,8 +383,7 @@ public interface RestOperations {
@@ -382,8 +383,7 @@ public interface RestOperations {
|
|
|
|
|
* @since 4.3.5 |
|
|
|
|
* @see HttpEntity |
|
|
|
|
* @see RestTemplate#setRequestFactory |
|
|
|
|
* @see org.springframework.http.client.HttpComponentsAsyncClientHttpRequestFactory |
|
|
|
|
* @see org.springframework.http.client.OkHttp3ClientHttpRequestFactory |
|
|
|
|
* @see org.springframework.http.client.HttpComponentsClientHttpRequestFactory |
|
|
|
|
*/ |
|
|
|
|
@Nullable |
|
|
|
|
<T> T patchForObject(String url, @Nullable Object request, Class<T> responseType, Object... uriVariables) |
|
|
|
|
@ -396,7 +396,7 @@ public interface RestOperations {
@@ -396,7 +396,7 @@ public interface RestOperations {
|
|
|
|
|
* <p>The {@code request} parameter can be a {@link HttpEntity} in order to |
|
|
|
|
* add additional HTTP headers to the request. |
|
|
|
|
* <p><b>NOTE: The standard JDK HTTP library does not support HTTP PATCH. |
|
|
|
|
* You need to use the Apache HttpComponents or OkHttp request factory.</b> |
|
|
|
|
* You need to use e.g. the Apache HttpComponents request factory.</b> |
|
|
|
|
* @param url the URL |
|
|
|
|
* @param request the object to be PATCHed (may be {@code null}) |
|
|
|
|
* @param responseType the type of the return value |
|
|
|
|
@ -405,8 +405,7 @@ public interface RestOperations {
@@ -405,8 +405,7 @@ public interface RestOperations {
|
|
|
|
|
* @since 4.3.5 |
|
|
|
|
* @see HttpEntity |
|
|
|
|
* @see RestTemplate#setRequestFactory |
|
|
|
|
* @see org.springframework.http.client.HttpComponentsAsyncClientHttpRequestFactory |
|
|
|
|
* @see org.springframework.http.client.OkHttp3ClientHttpRequestFactory |
|
|
|
|
* @see org.springframework.http.client.HttpComponentsClientHttpRequestFactory |
|
|
|
|
*/ |
|
|
|
|
@Nullable |
|
|
|
|
<T> T patchForObject(String url, @Nullable Object request, Class<T> responseType, |
|
|
|
|
@ -418,7 +417,7 @@ public interface RestOperations {
@@ -418,7 +417,7 @@ public interface RestOperations {
|
|
|
|
|
* <p>The {@code request} parameter can be a {@link HttpEntity} in order to |
|
|
|
|
* add additional HTTP headers to the request. |
|
|
|
|
* <p><b>NOTE: The standard JDK HTTP library does not support HTTP PATCH. |
|
|
|
|
* You need to use the Apache HttpComponents or OkHttp request factory.</b> |
|
|
|
|
* You need to use e.g. the Apache HttpComponents request factory.</b> |
|
|
|
|
* @param url the URL |
|
|
|
|
* @param request the object to be PATCHed (may be {@code null}) |
|
|
|
|
* @param responseType the type of the return value |
|
|
|
|
@ -426,8 +425,7 @@ public interface RestOperations {
@@ -426,8 +425,7 @@ public interface RestOperations {
|
|
|
|
|
* @since 4.3.5 |
|
|
|
|
* @see HttpEntity |
|
|
|
|
* @see RestTemplate#setRequestFactory |
|
|
|
|
* @see org.springframework.http.client.HttpComponentsAsyncClientHttpRequestFactory |
|
|
|
|
* @see org.springframework.http.client.OkHttp3ClientHttpRequestFactory |
|
|
|
|
* @see org.springframework.http.client.HttpComponentsClientHttpRequestFactory |
|
|
|
|
*/ |
|
|
|
|
@Nullable |
|
|
|
|
<T> T patchForObject(URI url, @Nullable Object request, Class<T> responseType) |
|
|
|
|
@ -491,8 +489,8 @@ public interface RestOperations {
@@ -491,8 +489,8 @@ public interface RestOperations {
|
|
|
|
|
// exchange
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Execute the HTTP method to the given URI template, writing the given request entity to the request, and |
|
|
|
|
* returns the response as {@link ResponseEntity}. |
|
|
|
|
* Execute the HTTP method to the given URI template, writing the given request entity to the request, |
|
|
|
|
* and return the response as {@link ResponseEntity}. |
|
|
|
|
* <p>URI Template variables are expanded using the given URI variables, if any. |
|
|
|
|
* @param url the URL |
|
|
|
|
* @param method the HTTP method (GET, POST, etc) |
|
|
|
|
@ -507,8 +505,8 @@ public interface RestOperations {
@@ -507,8 +505,8 @@ public interface RestOperations {
|
|
|
|
|
Class<T> responseType, Object... uriVariables) throws RestClientException; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Execute the HTTP method to the given URI template, writing the given request entity to the request, and |
|
|
|
|
* returns the response as {@link ResponseEntity}. |
|
|
|
|
* Execute the HTTP method to the given URI template, writing the given request entity to the request, |
|
|
|
|
* and return the response as {@link ResponseEntity}. |
|
|
|
|
* <p>URI Template variables are expanded using the given URI variables, if any. |
|
|
|
|
* @param url the URL |
|
|
|
|
* @param method the HTTP method (GET, POST, etc) |
|
|
|
|
@ -523,8 +521,8 @@ public interface RestOperations {
@@ -523,8 +521,8 @@ public interface RestOperations {
|
|
|
|
|
Class<T> responseType, Map<String, ?> uriVariables) throws RestClientException; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Execute the HTTP method to the given URI template, writing the given request entity to the request, and |
|
|
|
|
* returns the response as {@link ResponseEntity}. |
|
|
|
|
* Execute the HTTP method to the given URI template, writing the given request entity to the request, |
|
|
|
|
* and return the response as {@link ResponseEntity}. |
|
|
|
|
* @param url the URL |
|
|
|
|
* @param method the HTTP method (GET, POST, etc) |
|
|
|
|
* @param requestEntity the entity (headers and/or body) to write to the request |
|
|
|
|
@ -538,7 +536,7 @@ public interface RestOperations {
@@ -538,7 +536,7 @@ public interface RestOperations {
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Execute the HTTP method to the given URI template, writing the given |
|
|
|
|
* request entity to the request, and returns the response as {@link ResponseEntity}. |
|
|
|
|
* request entity to the request, and return the response as {@link ResponseEntity}. |
|
|
|
|
* The given {@link ParameterizedTypeReference} is used to pass generic type information: |
|
|
|
|
* <pre class="code"> |
|
|
|
|
* ParameterizedTypeReference<List<MyBean>> myBean = |
|
|
|
|
@ -561,7 +559,7 @@ public interface RestOperations {
@@ -561,7 +559,7 @@ public interface RestOperations {
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Execute the HTTP method to the given URI template, writing the given |
|
|
|
|
* request entity to the request, and returns the response as {@link ResponseEntity}. |
|
|
|
|
* request entity to the request, and return the response as {@link ResponseEntity}. |
|
|
|
|
* The given {@link ParameterizedTypeReference} is used to pass generic type information: |
|
|
|
|
* <pre class="code"> |
|
|
|
|
* ParameterizedTypeReference<List<MyBean>> myBean = |
|
|
|
|
@ -584,7 +582,7 @@ public interface RestOperations {
@@ -584,7 +582,7 @@ public interface RestOperations {
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Execute the HTTP method to the given URI template, writing the given |
|
|
|
|
* request entity to the request, and returns the response as {@link ResponseEntity}. |
|
|
|
|
* request entity to the request, and return the response as {@link ResponseEntity}. |
|
|
|
|
* The given {@link ParameterizedTypeReference} is used to pass generic type information: |
|
|
|
|
* <pre class="code"> |
|
|
|
|
* ParameterizedTypeReference<List<MyBean>> myBean = |
|
|
|
|
|