I have written a URL connection program, which would request a webpage from the server. I find that HTTP headers are missing from the the text that I get. Could anyone suggest what can I write more in this program so that I can get to see
HTTP/1.1 200 OK Content-Type: tex/html
apart from the usual <html> tags.
My program ==========
Request for Moderators: Please don't move it in HTML forums, because it is servlet programmers who deal with getting and setting of headers and not HTML programmers.
If you use Jakarta HttpClient instead of java.net.HttpUrlConnection, there's a class called HttpConnection which gives you access to the raw streams. Maybe that allows you to do that. I've never done it, so I can't help with that.
Added later: Looking at the URLConnection API, it does have getInputStream and getOutputStream methods, which may help you accomplish what you're trying to do. [ August 14, 2005: Message edited by: Ulf Dittmer ]
I attempted to reproduce a subset of HttpURLConnection using raw sockets because I wanted control over the socket timeout. It was entertaining, but a pretty big task. To do it you'd have to send all the headers and the request, read and parse all the headers and the response. Starting with the source for the HttpClient version would be a big jump start. Some place down inside it must do exactly that ... read the socket stream and interpret everything that comes through. Maybe you can just insert some hooks and make it call a listener for each header.
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
If your interest is to just understand the flow of headers, you can also use external tools like Ethereal,Paros etc which are good sniffers.This will help you to narrow down each and every bit transferred !!!