cwineman
asked on
URLConnection getHeaderField problem
Normally, the header returned by URLConnection.getHeaderFie ld(0) will return the http response code:
HTTP/1.0 200 OK
The response from this site:
http://satc.gsfc.nasa.gov/
is unknown/unknown
When I checked the first lines of the header using a socket, I found that the server actually returned:
HTTP 200 Document follows
I guess the lack of a version is confusing java. Is this a valid response ? Does the server have to include a version, or is there a problem in whatever URLConnection uses to parse the HTTP response ?
HTTP/1.0 200 OK
The response from this site:
http://satc.gsfc.nasa.gov/
is unknown/unknown
When I checked the first lines of the header using a socket, I found that the server actually returned:
HTTP 200 Document follows
I guess the lack of a version is confusing java. Is this a valid response ? Does the server have to include a version, or is there a problem in whatever URLConnection uses to parse the HTTP response ?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks for the answers.
My real problem is that when I try to open a URLConnection to that site, get the inputStream and read, it doesn't start with the content.
Normally the first bytes read from an html page will be "<html><head>...". On this site, the first things I read are:
HTTP 200 Document follows
.....other headers
I wasn't sure if it was because the server was doing something wrong, or java was screwing up reading the http response. I sounds like its the server according to heyhey.
The headers that vlad21 got are different than the ones that URLConnection gets. I think URLConnection must use a more simple "GET" request.
I'm not sure how to get around this using any standard java code. Looks like I need to find some other http client.
My real problem is that when I try to open a URLConnection to that site, get the inputStream and read, it doesn't start with the content.
Normally the first bytes read from an html page will be "<html><head>...". On this site, the first things I read are:
HTTP 200 Document follows
.....other headers
I wasn't sure if it was because the server was doing something wrong, or java was screwing up reading the http response. I sounds like its the server according to heyhey.
The headers that vlad21 got are different than the ones that URLConnection gets. I think URLConnection must use a more simple "GET" request.
I'm not sure how to get around this using any standard java code. Looks like I need to find some other http client.
U acn use sources from http://www.idssoftware.com/demos/trace.html
U can use sources from http://www.idssoftware.com/demos/trace.html
ASKER
vladi21,
Thanks for the info. The link on getting around a proxy server was helpful, but the link to the HTTP client appears to be broken. I am interested in finding another HTTP client if you know the address.
Thanks for the info. The link on getting around a proxy server was helpful, but the link to the HTTP client appears to be broken. I am interested in finding another HTTP client if you know the address.
as far a s I remember the server MUST return the HTTP version.
you can get the HTTP protocol definiton from www.faqs.org (check the STD section)