I need to implement a HTTP proxy server application which will proxy requests from multiple clients to a remote server.
Here are the steps:
I'm just not sure how I should implement this proxy. My first thought was to implement a tomcat application which uses jersey / apache httpclient to forward the request to the remote server and return the response back to the client ?
Is there a better way to implement such a proxy server ?
The proxy would need to handle multiple threads.
You can't implement it as a servlet, and there is no reason to use any form of HTTP client.
A featureless proxy server is a really simple thing:
Otherwise start two threads to copy bytes, one in each direction. Nothing fancy, just
while ((count = in.read(buffer)) > 0)
{
out.write(buffer, 0, count);
}
Or use Apache SQUID.
Check out LittleProxy -- it has built-in classes for incoming and outgoing requests; you can just write your code similarly to how you would handle a HTTP request in a servlet.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With