We have legacy code using Apache Http Client 4 that replaces a response entity from within a response interceptor:
public class GzipResponseInterceptor implements HttpResponseInterceptor
{
@Override
public void process(HttpResponse response, HttpContext context) throws HttpException, IOException
{
response.setEntity(new GzipDecompressingEntity(response.getEntity()));
}
}
The interface HttpResponse
for version 5 does not include a method for getting or setting the entity. The process
method includes an EntityDetails parameter to get some information about the entity, but you cannot use that to replace it.
The Javadoc for the interceptor mentions decorating an entity, but does not mention how to do that:
Interceptors can also manipulate content entities enclosed with messages. Usually this is accomplished by using the 'Decorator' pattern where a wrapper entity class is used to decorate the original entity.
Does anyone know how this is meant to be done?