|
|
|
@ -69,11 +69,11 @@ import org.springframework.web.util.UriTemplateHandler; |
|
|
|
* support of less frequent cases. |
|
|
|
* support of less frequent cases. |
|
|
|
* |
|
|
|
* |
|
|
|
* <p><strong>NOTE:</strong> As of 5.0, the non-blocking, reactive |
|
|
|
* <p><strong>NOTE:</strong> As of 5.0, the non-blocking, reactive |
|
|
|
* {@link org.springframework.web.reactive.client.WebClient WebClient} offers a |
|
|
|
* {@code org.springframework.web.reactive.client.WebClient} offers a |
|
|
|
* modern alternative to the {@code RestTemplate} with efficient support for |
|
|
|
* modern alternative to the {@code RestTemplate} with efficient support for |
|
|
|
* both sync and async, as well as streaming scenarios. The {@code RestTemplate} |
|
|
|
* both sync and async, as well as streaming scenarios. The {@code RestTemplate} |
|
|
|
* will be deprecated in a future version and will not have major new features |
|
|
|
* will be deprecated in a future version and will not have major new features |
|
|
|
* gong forward. |
|
|
|
* added going forward. |
|
|
|
* |
|
|
|
* |
|
|
|
* @author Arjen Poutsma |
|
|
|
* @author Arjen Poutsma |
|
|
|
* @author Brian Clozel |
|
|
|
* @author Brian Clozel |
|
|
|
@ -174,7 +174,7 @@ public class RestTemplate extends InterceptingHttpAccessor implements RestOperat |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Create a new instance of the {@link RestTemplate} based on the given {@link ClientHttpRequestFactory}. |
|
|
|
* Create a new instance of the {@link RestTemplate} based on the given {@link ClientHttpRequestFactory}. |
|
|
|
* @param requestFactory HTTP request factory to use |
|
|
|
* @param requestFactory the HTTP request factory to use |
|
|
|
* @see org.springframework.http.client.SimpleClientHttpRequestFactory |
|
|
|
* @see org.springframework.http.client.SimpleClientHttpRequestFactory |
|
|
|
* @see org.springframework.http.client.HttpComponentsClientHttpRequestFactory |
|
|
|
* @see org.springframework.http.client.HttpComponentsClientHttpRequestFactory |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@ -185,7 +185,7 @@ public class RestTemplate extends InterceptingHttpAccessor implements RestOperat |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Create a new instance of the {@link RestTemplate} using the given list of |
|
|
|
* Create a new instance of the {@link RestTemplate} using the given list of |
|
|
|
* {@link HttpMessageConverter} to use |
|
|
|
* {@link HttpMessageConverter} to use. |
|
|
|
* @param messageConverters the list of {@link HttpMessageConverter} to use |
|
|
|
* @param messageConverters the list of {@link HttpMessageConverter} to use |
|
|
|
* @since 3.2.7 |
|
|
|
* @since 3.2.7 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@ -633,7 +633,7 @@ public class RestTemplate extends InterceptingHttpAccessor implements RestOperat |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// general execution
|
|
|
|
// General execution
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
@Nullable |
|
|
|
@Nullable |
|
|
|
@ -732,39 +732,43 @@ public class RestTemplate extends InterceptingHttpAccessor implements RestOperat |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Returns a request callback implementation that prepares the request {@code Accept} |
|
|
|
* Return a {@code RequestCallback} that sets the request {@code Accept} |
|
|
|
* headers based on the given response type and configured |
|
|
|
* header based on the given response type, cross-checked against the |
|
|
|
* {@linkplain #getMessageConverters() message converters}. |
|
|
|
* configured message converters. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
protected <T> RequestCallback acceptHeaderRequestCallback(Class<T> responseType) { |
|
|
|
protected <T> RequestCallback acceptHeaderRequestCallback(Class<T> responseType) { |
|
|
|
return new AcceptHeaderRequestCallback(responseType); |
|
|
|
return new AcceptHeaderRequestCallback(responseType); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Returns a request callback implementation that writes the given object to the |
|
|
|
* Return a {@code RequestCallback} implementation that writes the given |
|
|
|
* request stream. |
|
|
|
* object to the request stream. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
protected <T> RequestCallback httpEntityCallback(@Nullable Object requestBody) { |
|
|
|
protected <T> RequestCallback httpEntityCallback(@Nullable Object requestBody) { |
|
|
|
return new HttpEntityRequestCallback(requestBody); |
|
|
|
return new HttpEntityRequestCallback(requestBody); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Returns a request callback implementation that writes the given object to the |
|
|
|
* Return a {@code RequestCallback} implementation that: |
|
|
|
* request stream. |
|
|
|
* <ol> |
|
|
|
|
|
|
|
* <li>Sets the request {@code Accept} header based on the given response |
|
|
|
|
|
|
|
* type, cross-checked against the configured message converters. |
|
|
|
|
|
|
|
* <li>Writes the given object to the request stream. |
|
|
|
|
|
|
|
* </ol> |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
protected <T> RequestCallback httpEntityCallback(@Nullable Object requestBody, Type responseType) { |
|
|
|
protected <T> RequestCallback httpEntityCallback(@Nullable Object requestBody, Type responseType) { |
|
|
|
return new HttpEntityRequestCallback(requestBody, responseType); |
|
|
|
return new HttpEntityRequestCallback(requestBody, responseType); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Returns a response extractor for {@link ResponseEntity}. |
|
|
|
* Return a {@code ResponseExtractor} that prepares a {@link ResponseEntity}. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
protected <T> ResponseExtractor<ResponseEntity<T>> responseEntityExtractor(Type responseType) { |
|
|
|
protected <T> ResponseExtractor<ResponseEntity<T>> responseEntityExtractor(Type responseType) { |
|
|
|
return new ResponseEntityResponseExtractor<>(responseType); |
|
|
|
return new ResponseEntityResponseExtractor<>(responseType); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Returns a response extractor for {@link HttpHeaders}. |
|
|
|
* Return a response extractor for {@link HttpHeaders}. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
protected ResponseExtractor<HttpHeaders> headersExtractor() { |
|
|
|
protected ResponseExtractor<HttpHeaders> headersExtractor() { |
|
|
|
return this.headersExtractor; |
|
|
|
return this.headersExtractor; |
|
|
|
|