-
Notifications
You must be signed in to change notification settings - Fork 38.8k
Closed
Labels
in: webIssues in web modules (web, webmvc, webflux, websocket)Issues in web modules (web, webmvc, webflux, websocket)type: enhancementA general enhancementA general enhancement
Milestone
Description
Stephan Oudmaijer opened SPR-7874 and commented
The org.springframework.web.client.RestTemplate does not support gzip encoding. Please add an option to add headers to the request or provide built-in support for gzip encoding.
Now I have added a hack in my own GzipRestTemplate version:
public class GzipRestTemplate extends RestTemplate {
@Override
protected <T> T doExecute(URI url, HttpMethod method, RequestCallback requestCallback, ResponseExtractor<T> responseExtractor) throws RestClientException {
Assert.notNull(url, "'url' must not be null");
Assert.notNull(method, "'method' must not be null");
ClientHttpResponse response = null;
try {
ClientHttpRequest request = createRequest(url, method);
if( request.getHeaders() != null ) {
request.getHeaders().add("Accept-Encoding", "gzip,deflate"); // <- hack
}
Affects: 3.0.5
Referenced from: commits 3d645cf
8 votes, 13 watchers
Metadata
Metadata
Assignees
Labels
in: webIssues in web modules (web, webmvc, webflux, websocket)Issues in web modules (web, webmvc, webflux, websocket)type: enhancementA general enhancementA general enhancement