I was getting having issues with this for quite some time. The following code will was working on text pages without the closes, but wouldn’t proxy a map image layer without them.
Assuming you have a “targetUrl” that you are trying to proxy then the following code should work.
This code does use an internal “Request” and “HTTPClient” object that wraps the ones from Apache to make it easier to use. But in this case isn’t the difficult bit.