Index: src/java/org/apache/ivy/util/url/BasicURLHandler.java =================================================================== --- src/java/org/apache/ivy/util/url/BasicURLHandler.java (revision 678620) +++ src/java/org/apache/ivy/util/url/BasicURLHandler.java (working copy) @@ -134,6 +134,19 @@ "Downloaded file size doesn't match expected Content Length for " + src + ". Please retry."); } + // We can only figure the content we got is want we want if the status is success. + if (srcConn instanceof HttpURLConnection) { + int status = ((HttpURLConnection) srcConn).getResponseCode(); + + if ((status / 100) != 2) { + dest.delete(); + String message = ((HttpURLConnection) srcConn).getResponseMessage(); + throw new IOException( + "The HTTP response code for " + src + " did not indicate success." + + " The response code was " + status + " the message being '" + message + "'." + + " Please retry."); + } + } long lastModified = srcConn.getLastModified(); if (lastModified > 0) { dest.setLastModified(lastModified); Index: src/java/org/apache/ivy/util/url/HttpClientHandler.java =================================================================== --- src/java/org/apache/ivy/util/url/HttpClientHandler.java (revision 678620) +++ src/java/org/apache/ivy/util/url/HttpClientHandler.java (working copy) @@ -91,6 +91,14 @@ public void download(URL src, File dest, CopyProgressListener l) throws IOException { GetMethod get = doGet(src); + // We can only figure the content we got is want we want if the status is success. + if ((get.getStatusCode() / 100) != 2) { + throw new IOException( + "The HTTP response code for " + src + " did not indicate success." + + " The response code was " + get.getStatusCode() + + " the message being '" + get.getStatusText() + "'." + + " Please retry."); + } FileUtil.copy(get.getResponseBodyAsStream(), dest, l); dest.setLastModified(getLastModified(get)); get.releaseConnection();