Good Evening Gentlemen,

I am trying to store response before it gets dispatched so that it can
be used for caching. I am not sure how to do it.

I am planning to implement ResponseHandler.

1. One way to get response content is to call response.getEntity().
However this just gives jaxb object that it is carrying.

2. Other way I can think of is

final OutputStream os = message.getContent(OutputStream.class);
       if (os == null) {
               LOG.debug("Outputstream with message was null");
           return;
       }
       final CacheAndWriteOutputStream newOut = new
CacheAndWriteOutputStream(os);
       message.setContent(OutputStream.class, newOut);
       StringBuilder builder=new StringBuilder();
       newOut.writeCacheTo(builder, "UTF-8");
               //ObjectConverter objectConverter=new ObjectConverter();
               byte[] content=builder.toString().getBytes("UTF-8");

However this is giving me empty content.

What I am missing ? and What is the standard way to do it.

Thank you.
Santos

Reply via email to