0
votes

I tried many things to gzip the request(in json) using camel, we are calling rest web services using camel.

The request will be in the body as we are sending it in POST request

I tried with adding content encoding as gzip, it does not worked

I tried to add a new data format gzip and giving but none of these worked.

Is there any way to gzip the input request, our need is to call a web service with the request as gzipped. I couldn't get much support from google, please help

Regards Hari

1

1 Answers

0
votes

I am not sure if i understood your requirement fully. But if you just want to gzip your body content you can use GZIPOutputStream and add a Content-Encoding header with value as gzip

String foo = "value";
ByteArrayOutputStream baos = new ByteArrayOutputStream();
gzos = null;
try {
 gzos = new GZIPOutputStream(baos);
 gzos.write(foo.getBytes("UTF-8"));
} finally {
if (gzos != null) try { gzos.close(); } catch (IOException ignore) {};
}
byte[] fooGzippedBytes = baos.toByteArray();