I`m using the class HttpURLConnection this way:
HttpURLConnection con=(HttpURLConnection) servlet.openConnection();
int conResponseCode = con.getResponseCode();
Sometimes I`m getting conResponseCode as 0.
I tried to look in the net, and couldnt find what it means?
any idea why it occours? and what it states for?
Thanks,
ray.
It’s not a valid HTTP response, so it doesn’t mean anything per se.
Looking at the source of
java.net.HttpURLConnection(which is what I presume you mean), it seems to just parse the integer status code out of the response line. Which would seem to imply that the remote server is returning a response along the lines of:(where XXX is some reason).
If you make the request yourself with telnet (or similar program), or can put breakpoints on Java sources in your debugger, you’ll be able to see what is being sent back from the remote server in this case.
Either way, this is either a bug in the Java libraries (possible, but unlikely) or a weird response from the remote server. Getting the raw contents of the response will allow you to distinguish between the two, and then ping the relevant party with a bug report.