Details
Description
If connecting through a proxy server, and authentication fails, maven provides a confusing message as shown below:
Attempting to download maven-SNAPSHOT.jar.
Error retrieving artifact from http://www.ibiblio.org/maven/maven/jars/maven-SNAPSHOT.jar: java.lang.Exception: Can't get maven-SNAPSHOT.jar to yadayadayada\.maven\repository\maven\jars\maven-SNAPSHOT.jar
So I added a few lines to HttpUtils to recognise the HTTP_PROXY_AUTH [407] return code and handle it similarily to the code already there for HTTP_UNAUTHORIZED [401]. The message is now:
Attempting to download maven-SNAPSHOT.jar.
Error retrieving artifact from http://www.ibiblio.org/maven/maven/jars/maven-SNAPSHOT.jar: java.lang.Exception: Not authorized by proxy.
I've provided a patch below.
---------------- PATCH START ----------------
Index: HttpUtils.java
===================================================================
RCS file: /home/cvspublic/maven/src/java/org/apache/maven/util/HttpUtils.java,v
retrieving revision 1.28
diff -c -r1.28 HttpUtils.java
-
-
- HttpUtils.java 27 Oct 2003 16:33:11 -0000 1.28
- HttpUtils.java 6 Feb 2004 09:37:53 -0000
***************
- 283,288 ****
- 283,295 ----
return;
throw new Exception( "Not authorized." );
}
+ // test for 407 result (HTTP only)
+ if ( httpConnection.getResponseCode() == HttpURLConnection.HTTP_PROXY_AUTH )
+ { + if (ignoreErrors) + return; + throw new Exception( "Not authorized by proxy." ); + }
}
-
// REVISIT: at this point even non HTTP connections may support the
----------------- PATCH END -----------------
Applied. Thanks.