SPR-5866 - RestTemplate - access to Request Headers

This commit is contained in:
Arjen Poutsma
2010-03-11 17:41:30 +00:00
parent 886eb665bf
commit b0e3081636
2 changed files with 23 additions and 5 deletions

View File

@@ -587,12 +587,21 @@ public class RestTemplate extends HttpAccessor implements RestOperations {
private final HttpMessageConverterExtractor<T> delegate;
public HttpEntityResponseExtractor(Class<T> responseType) {
this.delegate = new HttpMessageConverterExtractor<T>(responseType, getMessageConverters());
if (responseType != null) {
this.delegate = new HttpMessageConverterExtractor<T>(responseType, getMessageConverters());
} else {
this.delegate = null;
}
}
public HttpEntity<T> extractData(ClientHttpResponse response) throws IOException {
T body = delegate.extractData(response);
return new HttpEntity<T>(body, response.getHeaders());
if (delegate != null) {
T body = delegate.extractData(response);
return new HttpEntity<T>(body, response.getHeaders());
}
else {
return new HttpEntity<T>(response.getHeaders());
}
}
}