• Post Reply Bookmark Topic Watch Topic
  • New Topic

Developing a proxy server  RSS feed

 
Raghav Mathur
Ranch Hand
Posts: 641
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI
I,am working on the development of a a proxy server. I,am using the java.net.Url class for the purpose . Right now I,am trying to handle HTTP . Retrieving the data using GET method has been done successfully but as far as posting data to a URL is concerned I,am not able to do it.
Another issue is that according to the design a web client first connect to my proxy server and the proxy server after connecting makes a connection to the URL requested by the web client ( internet browser ). In the process it does not transfers the full header information. For example
HTTP_ACCEPT:text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2 HTTP_CONNECTION:keep-alive HTTP_HOST:abc HTTP_USER_AGENT:Java1.4.0-beta .
This is the header information when I,am using my proxy server but if I,am not then I receive ,
HTTP_ACCEPT:image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/vnd.ms-powerpoint, application/vnd.ms-excel, application/msword, */* HTTP_ACCEPT_LANGUAGE:en-us HTTP_CONNECTION:Keep-Alive HTTP_HOST:vikram HTTP_REFERER:http://abc/test2/get.html HTTP_USER_AGENT:Mozilla/4.0 (compatible; MSIE 5.5; Windows 98) HTTP_ACCEPT_ENCODING:gzip, deflate
Now the data which has to be written on to the server(URL) resides in the Header (The last value in the header). So do I just need to extract the last value and write it to the url or do I need to write the full header through output streams. Also when I,am using GET method for a url connection ,at that time also I need to send this header information to the server(URL). Right now I,am sending the full header.
Thanks in advance.
 
Raghav Mathur
Ranch Hand
Posts: 641
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please help me people ... this is urgent.
Thanks in advance.
 
Peter den Haan
author
Ranch Hand
Posts: 3252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I understand, but it is hard to get a handle on what your problem is. Hence no response, I think. Also I personally do not have a lot of time at the moment, I'm writing some stuff for a JSP 2 book on a very tight deadline.
To be honest, I have this general gut feeling that you are stretching the URL class a bit. You have to code an HTTP server anyway, I would be tempted to roll my own client as well. Some things might even become simpler.
I suspect POST doesn't work because you are writing part of the incoming request header to the outgoing request (URL) body (from the code you sent in a private message).
Beware that writing a robust proxy is not easy. There are many more methods to support than just GET and POST, you have to be aware of keepalive connections, and the HTTP spec has some specific protocol support for proxies to ensure they act really transparently.
- Peter
 
Raghav Mathur
Ranch Hand
Posts: 641
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hmmm ... i understand the problems i would be facing while developing a proxy server . I just accomplished something. I'll let you know the details in my next post . I understand that you'd be busy with your book writing but if possible for you then kindly try helping me out with my problems . Gotta run now .
[ November 17, 2002: Message edited by: raghav mathur ]
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!