Link to home
Start Free TrialLog in
Avatar of cwineman
cwineman

asked on

URLConnection getHeaderField problem

Normally, the header returned by URLConnection.getHeaderField(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 ?
ASKER CERTIFIED SOLUTION
Avatar of vladi21
vladi21

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of heyhey_
heyhey_

>> Does the server have to include

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)
Avatar of cwineman

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.
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.