0

In our application, we are making REST calls to the database and passing huge chunk of JSON data. We would like to compress the JSON so as to speed up the data transfer process.

LinkedHashMap<String, Object> mapObject;
        mapObject = objectMapper.readValue(JsonPayLoad.toString(), new TypeReference<LinkedHashMap<String, Object>>()
        {});

ResponseEntity<Object> responseEntity =
            restTemplate.postForEntity(executeTxUrl, mapObject, Object.class, txId);

I don't think this can be achieved by simply setting some http header. I think it would require an explicit compression of the JSON.

Also, I think it can be tested through the application's http logs?

Please let me know if someone has done something similar.

Regards, Rahul

Rahul
  • 637
  • 5
  • 16
  • Please see http://stackoverflow.com/questions/27446912/sending-gzip-compressed-data-with-spring-android-resttemplate – Thanh Nguyen Van May 20 '16 at 08:20
  • That article seems to be for spring-android. I'm using org.springframework.http.HttpHeaders and it doesn't have headers.setContentEncoding() method. It does have a similar method : headers.setContentType() but GZIP MediaType doesn't exist. – Rahul May 20 '16 at 08:37
  • Did you try `headers.set(HttpHeaders.CONTENT_ENCODING, "gzip");`? – Thanh Nguyen Van May 20 '16 at 09:07
  • I was take a look at source code and I think Spring has no built in support for sending http request with gzip enabled! – Thanh Nguyen Van May 20 '16 at 09:39

0 Answers0