Hello,

I have been tasked to write a cool Http Proxy that will sit in front of
Squid.  I dug around jakarta remembering I saw an HttpClient project there a
few years ago and I stumbled upon HttpComponents.  I know its in the early
stages but so far it has most of what I need.  I am not an http guru but I
can figure most things out if I Bang my head against it enough.

Anyway I have a very simple test proxy server working.  I am at the point
where I want to manipulate the response on the way back.  I had placed in my
code a log message to dump its contents out before I changed it.  Then I
kept getting error messages about the content being consumed.  So I checked
the source code and it turns out once you get the Content you cannot get it
again.

What I want to do is this:

HttpEntity entity = response1.getEntity();
modifyResponseContent( entity ); // this will get the content and change it
response2.setEntity( entity );

Where response1 is the response from the webserver and response2 is the
response from the proxyserver back to the client.

Why is this restriction in place and how can I go about doing this a
different way?

I thought about reading the content from the InputStream and then creating
another one to create another Entity to put in the client response.  However
There seem to be so many specific Entity types how do I know which one to
choose?

thanks in advance!

Doug



--
What profits a man if he gains the whole world yet loses his soul?

Reply via email to