Re: How to send response headers from proxy to browser?



hiwa wrote:

This question's got no replies on forum.java.sun.com
through its full four days and three nights life.

Tut! Bunch of wasters...

;-)


The proxy server intercepts every request from the
browser and redirect it to www.yahoo.com. It simply
discards original request. After connecting to yahoo.com,
it sends the received response to the browser,
displaying the first part of the yahoo page. However,
as described in the comment on the code below, it
seems the proxy can't send the response headers to
the browser, it only sends document content. What
should we do to send the response headers from proxy?

Get hold of a copy of Ethereal, and watch what data /really/ goes back and
forth. No arguments, just do it ! You are only wasting your own time if you
try to debug any kind of networking code without a tool like Ethereal.

I suspect that the problem is that you are not correlating what the client sees
with what Yahoo sends back. When you send your request to Yahoo, you have set
a lot of stuff about Keep-Alives, and so so. You then copy /all/ of the client
request onto what you've already set (which is wrong -- e.g. you'll have two
GET lines, although Yahoo'll ignore the second bunch since it'll see them as
the body of the GET request). When it sends back a response, it will be
formatted (keep-alives, compression, etc) in accordance with the settings you
established (ignoring what the client asked for), but you then just copy
Yahoo's answer back to the client -- which will probably get very confused...

I doubt whether the Java HTTP stuff is the right tool to use for this job.
You'd almost certainly be better off working at the level of raw sockets, since
you will need the level of control that gives you. It'll also be easier to see
what's going on, and so probably easier to code too. BTW, you will also need
(if you don't have it already) a reasonable knowledge of the HTTP protocol --
it's not enough just to know how to use HttpURLConnection and its friends.

-- chris


.



Relevant Pages

  • Re: HELP - hiding basic http authentication
    ... However, it does mean there isnt a way of logging in for the client, ... to the camera so the user dosent get the password. ... with the request from your user's browser to the webserver. ... Browser request a webpage from the server. ...
    (php.general)
  • How to send response headers from proxy to browser?
    ... The proxy server intercepts every request from the ... browser and redirect it to www.yahoo.com. ... should we do to send the response headers from proxy? ...
    (comp.lang.java.programmer)
  • Re: openssl from tcl
    ... "gets $fp" to retrieve the request from the web browser. ... I send a response back to the browser, using "puts $fp 'html data'", ... Because you made the client connect to localhost, ...
    (comp.lang.tcl)
  • Re: Which way to go?
    ... > which has a browser available. ... profile) is sent to the client and the user would like to see ... graph figures) - this would entail making a server request every time, ...
    (comp.lang.java.programmer)
  • RE: DNS response Issue
    ... The browser depends on OS settings for name resolution. ... TCP/IP settings on the NIC point to the server for DNS ... >> 2 computers connected to the Switch (One a server another a client), ... >> client is removed from the LAN so any request from the client has to go ...
    (microsoft.public.win2000.dns)