-
Bug
-
Resolution: Duplicate
-
P2
-
None
-
1.3.1
-
sparc
-
solaris_8
The method getResponseCode() in HttpURLConnection calls
it's getInputStream() method, which extracts the response code
from the HTTP response. According to the API doc, and common
sense, it should return the response code specified by the server
in the HTTP response. But when the response code specified is
>=400, it does not return the code, instead it throws a FileNotFoundException.
This is totally misleading, because the URL was indeed found, and generated
a valid error response, which is thrown away by HttpURLConnection, so the
client can never see it, or handle it. This behavior is completely
inappropriate.
It is true that HttpURLConnection does not generate the FileNotFoundException
if the URL in question ends in ".htm", "/", or ".txt", but the point is,
that it should NEVER throw a FileNotFoundException if it gets a response
from the server for the given URL, no matter what the URL is or what the
response is.
it's getInputStream() method, which extracts the response code
from the HTTP response. According to the API doc, and common
sense, it should return the response code specified by the server
in the HTTP response. But when the response code specified is
>=400, it does not return the code, instead it throws a FileNotFoundException.
This is totally misleading, because the URL was indeed found, and generated
a valid error response, which is thrown away by HttpURLConnection, so the
client can never see it, or handle it. This behavior is completely
inappropriate.
It is true that HttpURLConnection does not generate the FileNotFoundException
if the URL in question ends in ".htm", "/", or ".txt", but the point is,
that it should NEVER throw a FileNotFoundException if it gets a response
from the server for the given URL, no matter what the URL is or what the
response is.
- duplicates
-
JDK-4160499 sun.net.www.protocol.http.HttpURLConnection error handling
- Resolved