mitre/HTTP-Proxy-Servlet

Compressed Content not Supported

Closed this issue · 3 comments

Hi,

using the proxy within any intermediate content processing becomes challenging in case the server returns a compressed response.

To enable this, the ProxyServlet should be modified on line 176 and 184 to wrap the created HttpClient with a DecompressingHttpClient.

For example, line 176 should be modified from
return new (HttpClient) constructor.newInstance(hcParams);
to
return new DecompressingHttpClient((HttpClient) constructor.newInstance(hcParams));

Similar Line 184 should be adapted and the according import is required.

Note: The class is deprecated in newer versions of the Apache HttpClient library. However, the same applies to the rest of the code.

regards

  • benjamin

Hello Benjamin,
Could you please elaborate what goes wrong today if this isn't done? If the server returns a response that is compressed, won't it simply be passed to the original client who can deal with it?

Hi David,yes, it is passed by. The trouble begins if you would like to work with the data in between. For example, in our case we need to do some url rewriting inside the proxy. The best way to do this is to use wrapping output streams observing patterns to be replaced. If the data is compressed, the data flowing through the streams cannot be observed to recognize those patterns.Maybe, a configuration parameter to choose to decompress compressed responses or not would be the +1 solution.regards- benjamin David Smiley notifications@github.com hat am 1. März 2016 um 05:19 geschrieben:Hello Benjamin, Could you please elaborate what goes wrong today if this isn't done? If the server returns a response that is compressed, won't it simply be passed to the original client who can deal with it?—Reply to this email directly or view it on GitHub.  

I think this is within the realm of options a user can choose to do themselves as you have already done. It's easy enough and the need to do this already implies that the user is subclassing the servlet. There are lots of configuration options on the HttpClientBuilder; this is just one.