continuum-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dariusz Nowak" <dariusz.a.no...@wp.pl>
Subject Problems with MungedHttpsURL
Date Mon, 10 Sep 2007 13:26:13 GMT
Dear Developers,

For a long time I have tried to be able to add a new Maven2 project from 
our SVN repository.
Unfortunately it was not possible neither in 1.0.2 nor 1.1-b2.

Finally I have found the cause of problems. It is the MungedHttpsURL 
class. I do not know why but it does not work with my company's SVN 
server. Every time I tried to create a new project 401 HTTP error was 
returned to the continuum.

After hacking continuum to use HttpClient everything started to work. 
Attached my changes.

Please let me know what information you need to fix the issue in future 
releases.

BR,
Dariusz


--- 
src/main/java/org/apache/maven/continuum/project/builder/AbstractContinuumProjectBuilder.java

      (revision 572578)
+++ 
src/main/java/org/apache/maven/continuum/project/builder/AbstractContinuumProjectBuilder.java

      (working copy)
@@ -34,6 +34,10 @@
 import java.net.URL;
 import java.net.UnknownHostException;

+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.UsernamePasswordCredentials;
+import org.apache.commons.httpclient.methods.GetMethod;
+
 /**
  * @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
  * @version $Id$
@@ -51,11 +55,32 @@
         getLogger().info( "Downloading " + metadata.toExternalForm() );

         InputStream is = null;
+
+        GetMethod get = null;

         if ( metadata.getProtocol().startsWith( "http" ) )
         {
-            is =
-                new MungedHttpsURL( metadata.toExternalForm(), 
username, password ).getURLConnection().getInputStream();
+
+//            is =
+//                new MungedHttpsURL( metadata.toExternalForm(), 
username, password ).getURLConnection().getInputStream();
+            HttpClient client = new HttpClient();
+
+            getLogger().info("Using HttpClient to get the resource, 
credentials - user: " + username + ", password: " + password);
+
+            if (username != null) {
+                client.getState().setCredentials(null, null, new 
UsernamePasswordCredentials(username, password));
+            }
+
+            get = new GetMethod(metadata.toExternalForm());
+
+            if (username != null) {
+                get.setDoAuthentication(true);
+            }
+            int status = client.executeMethod(get);
+
+            getLogger().info("Request status: " + status);
+
+            is = get.getResponseBodyAsStream();
         }
         else
         {
@@ -115,6 +140,9 @@
         is.close();

         writer.close();
+        if (get != null) {
+                get.releaseConnection();
+        }

         return file;
     }



Mime
View raw message