Groups | Search | Server Info | Keyboard shortcuts | Login | Register


Groups > comp.lang.java.programmer > #5674

Re: HTTP traffic over a custom proxy server?

From Tom Anderson <twic@urchin.earth.li>
Newsgroups comp.lang.java.programmer
Subject Re: HTTP traffic over a custom proxy server?
Date 2011-06-25 23:49 +0100
Organization Stack Usenet News Service
Message-ID <alpine.DEB.2.00.1106252300500.10866@urchin.earth.li> (permalink)
References <60701286-eb78-421a-8d54-b48762480994@glegroupsg2000goo.googlegroups.com>

Show all headers | View raw


On Fri, 24 Jun 2011, Knorpi wrote:

> I would like to setup a server "myserver" that acts as a proxy for its 
> clients. The clients pass the url of the web page they want in a query 
> string:
>
> - client sends a HTTP request:
>  http://myserver?url=www.foreignurl.com&par2=val1
>
> - Servlet on myserver extracts url from query string:
>  www.foreignurl.com
>
> - Servlet sends HTTP request to other server with query string:
>  http://www.foreignurl.com?par1=val1

This seems a mildly odd way of doing this. As Stefan suggests, it might be 
better to do whatever it is you're doing as a normal, proper, proxy 
server.

> - Servlet renders complete response from other server
>  into a String "content"
>
> - Servlet changes every link in the content to point to myserver
>  so that all links are accessed the same way
>
> - Servlet sends response to client
>
> The most important part would be to change all links in the response.
> Can you give me some hints how to do this?

If you're going to do it properly, you really need to parse the HTML, 
identify all the a elements which have hrefs, rewrite each of those, and 
write out the modified HTML. Doing this in the face of bad HTML, and doing 
it in such a way that it won't radically alter the pages, may be quite 
tricky.

tom

-- 
IMPORTANCE MEMO: >>> WHEN YOU BUY AN N-GAGE QD <<< PLEASE, please CONTINUE
TO TALK ON THE SIDE!!$ Note: the other party will not be able to hear you,
BUT WHO REALLY CRAPS A THING, SIDETALKIN' 2009++!!!

Back to comp.lang.java.programmer | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

HTTP traffic over a custom proxy server? Knorpi <alpineblaster@googlemail.com> - 2011-06-24 03:24 -0700
  Re: HTTP traffic over a custom proxy server? Tom Anderson <twic@urchin.earth.li> - 2011-06-25 23:49 +0100
  Re: HTTP traffic over a custom proxy server? Roedy Green <see_website@mindprod.com.invalid> - 2011-06-25 16:08 -0700
  Re: HTTP traffic over a custom proxy server? Esmond Pitt <esmond.pitt@bigpond.com> - 2011-06-27 20:28 +1000
  Re: HTTP traffic over a custom proxy server? Silvio <silvio@moc.com> - 2011-06-28 09:22 +0200

csiph-web