HttpURLConnection.getResponseCode throws FileNotFoundException if the
HTTP response code is >=400.
When calling HttpURLConnection.getResponseCode to obtain the HTTP
response code, this method apparently invokes
HttpURLConnection.getInputStream. However, getInputStream will throw
an FileNotFoundException if the HTTP response code is >=400 and the
URL does not end with either ".html", ".htm", "/" or ".txt".
This problem prohibits us from using HttpURLConnection to connect to
non-HTML based URL.
HTTP response code is >=400.
When calling HttpURLConnection.getResponseCode to obtain the HTTP
response code, this method apparently invokes
HttpURLConnection.getInputStream. However, getInputStream will throw
an FileNotFoundException if the HTTP response code is >=400 and the
URL does not end with either ".html", ".htm", "/" or ".txt".
This problem prohibits us from using HttpURLConnection to connect to
non-HTML based URL.
- duplicates
-
JDK-4160499 sun.net.www.protocol.http.HttpURLConnection error handling
-
- Resolved
-