maven-wagon-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject svn commit: r366124 - /maven/wagon/trunk/wagon-providers/wagon-http-lightweight/src/main/java/org/apache/maven/wagon/providers/http/LightweightHttpWagon.java
Date Thu, 05 Jan 2006 08:42:24 GMT
Author: brett
Date: Thu Jan  5 00:42:20 2006
New Revision: 366124

URL: http://svn.apache.org/viewcvs?rev=366124&view=rev
Log:
[WAGONHTTP-3] add ability to enable cache usage

Modified:
    maven/wagon/trunk/wagon-providers/wagon-http-lightweight/src/main/java/org/apache/maven/wagon/providers/http/LightweightHttpWagon.java

Modified: maven/wagon/trunk/wagon-providers/wagon-http-lightweight/src/main/java/org/apache/maven/wagon/providers/http/LightweightHttpWagon.java
URL: http://svn.apache.org/viewcvs/maven/wagon/trunk/wagon-providers/wagon-http-lightweight/src/main/java/org/apache/maven/wagon/providers/http/LightweightHttpWagon.java?rev=366124&r1=366123&r2=366124&view=diff
==============================================================================
--- maven/wagon/trunk/wagon-providers/wagon-http-lightweight/src/main/java/org/apache/maven/wagon/providers/http/LightweightHttpWagon.java
(original)
+++ maven/wagon/trunk/wagon-providers/wagon-http-lightweight/src/main/java/org/apache/maven/wagon/providers/http/LightweightHttpWagon.java
Thu Jan  5 00:42:20 2006
@@ -50,9 +50,16 @@
     private String previousProxyHost;
 
     private String previousProxyPort;
-    
+
     private HttpURLConnection putConnection;
 
+    /**
+     * Whether to use any proxy cache or not.
+     *
+     * @component.configuration default="false"
+     */
+    private boolean useCache;
+
     public void fillInputData( InputData inputData )
         throws TransferFailedException, ResourceDoesNotExistException
     {
@@ -71,8 +78,10 @@
                 url = new URL( repositoryUrl + "/" + resource.getName() );
             }
             URLConnection urlConnection = url.openConnection();
-            // TODO: make this configurable
-            urlConnection.setRequestProperty( "Pragma", "no-cache" );
+            if ( !useCache )
+            {
+                urlConnection.setRequestProperty( "Pragma", "no-cache" );
+            }
             inputData.setInputStream( urlConnection.getInputStream() );
             resource.setLastModified( urlConnection.getLastModified() );
             resource.setContentLength( urlConnection.getContentLength() );
@@ -96,7 +105,7 @@
     {
         Repository repository = getRepository();
         String repositoryUrl = repository.getUrl();
-        
+
         Resource resource = outputData.getResource();
         try
         {
@@ -110,36 +119,38 @@
                 url = new URL( repositoryUrl + "/" + resource.getName() );
             }
             putConnection = (HttpURLConnection) url.openConnection();
-            
-            putConnection.setRequestMethod("PUT");
-            putConnection.setDoOutput(true);
-            outputData.setOutputStream(putConnection.getOutputStream());
+
+            putConnection.setRequestMethod( "PUT" );
+            putConnection.setDoOutput( true );
+            outputData.setOutputStream( putConnection.getOutputStream() );
         }
         catch ( IOException e )
         {
             throw new TransferFailedException( "Error transferring file", e );
         }
     }
-    
-    
+
+
     public void put( File source, String resourceName )
         throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
     {
         super.put( source, resourceName );
-        
+
         try
         {
             if ( putConnection.getResponseCode() != HttpURLConnection.HTTP_OK )
             {
-                throw new TransferFailedException("Unable to transfer file. HttpURLConnection
returned the response code: " + putConnection.getResponseCode() );
+                throw new TransferFailedException(
+                    "Unable to transfer file. HttpURLConnection returned the response code:
" +
+                        putConnection.getResponseCode() );
             }
         }
         catch ( IOException e )
         {
-            throw new TransferFailedException("Error transferring file", e);
+            throw new TransferFailedException( "Error transferring file", e );
         }
     }
-    
+
 
     public void openConnection()
         throws ConnectionException, AuthenticationException



---------------------------------------------------------------------
To unsubscribe, e-mail: wagon-commits-unsubscribe@maven.apache.org
For additional commands, e-mail: wagon-commits-help@maven.apache.org


Mime
View raw message