Re: How to send response headers from proxy to browser?
- From: "Chris Uppal" <chris.uppal@xxxxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Mon, 20 Mar 2006 13:28:03 -0000
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
.
- Follow-Ups:
- Re: How to send response headers from proxy to browser?
- From: Thomas Hawtin
- Re: How to send response headers from proxy to browser?
- From: Thomas Weidenfeller
- Re: How to send response headers from proxy to browser?
- References:
- Prev by Date: Formatting numbers with spaces between them
- Next by Date: Re: Multiple Inheritance
- Previous by thread: How to send response headers from proxy to browser?
- Next by thread: Re: How to send response headers from proxy to browser?
- Index(es):
Relevant Pages
|