maven-wagon-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jvan...@apache.org
Subject svn commit: r433171 - in /maven/wagon/trunk/wagon-providers: wagon-http-lightweight/src/main/java/org/apache/maven/wagon/providers/http/ wagon-http/src/main/java/org/apache/maven/wagon/providers/http/ wagon-webdav/src/main/java/org/apache/maven/wagon/p...
Date Mon, 21 Aug 2006 06:31:45 GMT
Author: jvanzyl
Date: Sun Aug 20 23:31:44 2006
New Revision: 433171

URL: http://svn.apache.org/viewvc?rev=433171&view=rev
Log:
[WAGON-55] Applying patch which provides support for HTTP compression
Submitted By: Nathan Beyer (Cerner)


Modified:
    maven/wagon/trunk/wagon-providers/wagon-http-lightweight/src/main/java/org/apache/maven/wagon/providers/http/LightweightHttpWagon.java
    maven/wagon/trunk/wagon-providers/wagon-http/src/main/java/org/apache/maven/wagon/providers/http/HttpWagon.java
    maven/wagon/trunk/wagon-providers/wagon-webdav/src/main/java/org/apache/maven/wagon/providers/webdav/CorrectedWebdavResource.java
    maven/wagon/trunk/wagon-providers/wagon-webdav/src/main/java/org/apache/maven/wagon/providers/webdav/WebDavWagon.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/viewvc/maven/wagon/trunk/wagon-providers/wagon-http-lightweight/src/main/java/org/apache/maven/wagon/providers/http/LightweightHttpWagon.java?rev=433171&r1=433170&r2=433171&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
Sun Aug 20 23:31:44 2006
@@ -27,6 +27,7 @@
 import java.net.URL;
 import java.net.URLConnection;
 import java.util.List;
+import java.util.zip.GZIPInputStream;
 
 import org.apache.maven.wagon.ConnectionException;
 import org.apache.maven.wagon.InputData;
@@ -70,11 +71,19 @@
         {
             URL url = resolveResourceURL( resource );
             URLConnection urlConnection = url.openConnection();
+            urlConnection.setRequestProperty( "Accept-Encoding", "gzip" );
             if ( !useCache )
             {
                 urlConnection.setRequestProperty( "Pragma", "no-cache" );
             }
-            inputData.setInputStream( urlConnection.getInputStream() );
+            InputStream is = urlConnection.getInputStream();
+            String contentEncoding = urlConnection.getHeaderField( "Content-Encoding" );
+            boolean isGZipped = contentEncoding == null ? false : "gzip".equalsIgnoreCase(contentEncoding);
+            if (isGZipped)
+            {
+                is = new GZIPInputStream( is );
+            }
+            inputData.setInputStream( is );
             resource.setLastModified( urlConnection.getLastModified() );
             resource.setContentLength( urlConnection.getContentLength() );
         }

Modified: maven/wagon/trunk/wagon-providers/wagon-http/src/main/java/org/apache/maven/wagon/providers/http/HttpWagon.java
URL: http://svn.apache.org/viewvc/maven/wagon/trunk/wagon-providers/wagon-http/src/main/java/org/apache/maven/wagon/providers/http/HttpWagon.java?rev=433171&r1=433170&r2=433171&view=diff
==============================================================================
--- maven/wagon/trunk/wagon-providers/wagon-http/src/main/java/org/apache/maven/wagon/providers/http/HttpWagon.java
(original)
+++ maven/wagon/trunk/wagon-providers/wagon-http/src/main/java/org/apache/maven/wagon/providers/http/HttpWagon.java
Sun Aug 20 23:31:44 2006
@@ -25,6 +25,7 @@
 import java.util.List;
 import java.util.Locale;
 import java.util.TimeZone;
+import java.util.zip.GZIPInputStream;
 
 import org.apache.commons.httpclient.Credentials;
 import org.apache.commons.httpclient.Header;
@@ -264,6 +265,7 @@
             getMethod.addRequestHeader( "Cache-store", "no-store" );
             getMethod.addRequestHeader( "Pragma", "no-cache" );
             getMethod.addRequestHeader( "Expires", "0" );
+            getMethod.addRequestHeader( "Accept-Encoding", "gzip" );
 
             if ( timestamp > 0 )
             {
@@ -312,7 +314,7 @@
                         "Failed to transfer file: " + url + " after " + attempt + " attempts"
);
 
                 case HttpStatus.SC_FORBIDDEN:
-                    throw new AuthorizationException( "Access denided to: " + url );
+                    throw new AuthorizationException( "Access denied to: " + url );
 
                 case HttpStatus.SC_UNAUTHORIZED:
                     throw new AuthorizationException( "Not authorized." );
@@ -326,7 +328,7 @@
                     //add more entries here
                 default :
                     throw new TransferFailedException(
-                        "Failed to trasfer file: " + url + ". Return code is: " + statusCode
);
+                        "Failed to transfer file: " + url + ". Return code is: " + statusCode
);
             }
 
             InputStream is = null;
@@ -369,10 +371,17 @@
             if ( timestamp < lastModified )
             {
                 retValue = true;
+                
+                Header contentEncoding = getMethod.getResponseHeader( "Content-Encoding"
);
+                boolean isGZipped = contentEncoding == null ? false : "gzip".equalsIgnoreCase(contentEncoding.getValue());
 
                 try
                 {
                     is = getMethod.getResponseBodyAsStream();
+                    if (isGZipped)
+                    {
+                        is = new GZIPInputStream( is );
+                    }
 
                     getTransfer( resource, destination, is );
                 }
@@ -390,7 +399,7 @@
                         }
                     }
 
-                    String msg = "Error occured while deploying to remote repository:" +
getRepository();
+                    String msg = "Error occurred while deploying to remote repository:" +
getRepository();
 
                     throw new TransferFailedException( msg, e );
                 }
@@ -497,7 +506,7 @@
                     //add more entries here
                 default :
                     throw new TransferFailedException(
-                        "Failed to trasfer file: " + url + ". Return code is: " + statusCode
);
+                        "Failed to transfer file: " + url + ". Return code is: " + statusCode
);
             }
 
             InputStream is = null;
@@ -558,7 +567,7 @@
                         + " attempts" );
 
                 case HttpStatus.SC_FORBIDDEN:
-                    throw new AuthorizationException( "Access denided to: " + url );
+                    throw new AuthorizationException( "Access denied to: " + url );
 
                 case HttpStatus.SC_UNAUTHORIZED:
                     throw new AuthorizationException( "Not authorized." );
@@ -571,7 +580,7 @@
 
                     //add more entries here
                 default:
-                    throw new TransferFailedException( "Failed to trasfer file: " + url +
". Return code is: "
+                    throw new TransferFailedException( "Failed to transfer file: " + url
+ ". Return code is: "
                         + statusCode );
             }
         }

Modified: maven/wagon/trunk/wagon-providers/wagon-webdav/src/main/java/org/apache/maven/wagon/providers/webdav/CorrectedWebdavResource.java
URL: http://svn.apache.org/viewvc/maven/wagon/trunk/wagon-providers/wagon-webdav/src/main/java/org/apache/maven/wagon/providers/webdav/CorrectedWebdavResource.java?rev=433171&r1=433170&r2=433171&view=diff
==============================================================================
--- maven/wagon/trunk/wagon-providers/wagon-webdav/src/main/java/org/apache/maven/wagon/providers/webdav/CorrectedWebdavResource.java
(original)
+++ maven/wagon/trunk/wagon-providers/wagon-webdav/src/main/java/org/apache/maven/wagon/providers/webdav/CorrectedWebdavResource.java
Sun Aug 20 23:31:44 2006
@@ -21,7 +21,9 @@
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.Map;
+import java.util.zip.GZIPInputStream;
 
+import org.apache.commons.httpclient.Header;
 import org.apache.commons.httpclient.HttpMethod;
 import org.apache.commons.httpclient.HttpStatus;
 import org.apache.commons.httpclient.HttpURL;
@@ -100,6 +102,13 @@
 
         if ( isHttpSuccess( statusCode ) )
         {
+            Header contentEncoding = method.getResponseHeader( "Content-Encoding" );
+            boolean isGZipped = contentEncoding == null ? false : "gzip".equalsIgnoreCase(contentEncoding.getValue());
+            
+            if (isGZipped)
+            {
+                return new GZIPInputStream(method.getResponseBodyAsStream());
+            }
             return method.getResponseBodyAsStream();
         }
         else

Modified: maven/wagon/trunk/wagon-providers/wagon-webdav/src/main/java/org/apache/maven/wagon/providers/webdav/WebDavWagon.java
URL: http://svn.apache.org/viewvc/maven/wagon/trunk/wagon-providers/wagon-webdav/src/main/java/org/apache/maven/wagon/providers/webdav/WebDavWagon.java?rev=433171&r1=433170&r2=433171&view=diff
==============================================================================
--- maven/wagon/trunk/wagon-providers/wagon-webdav/src/main/java/org/apache/maven/wagon/providers/webdav/WebDavWagon.java
(original)
+++ maven/wagon/trunk/wagon-providers/wagon-webdav/src/main/java/org/apache/maven/wagon/providers/webdav/WebDavWagon.java
Sun Aug 20 23:31:44 2006
@@ -278,7 +278,7 @@
                     break;
 
                 case HttpStatus.SC_FORBIDDEN:
-                    throw new AuthorizationException( "Access denided to: " + dest );
+                    throw new AuthorizationException( "Access denied to: " + dest );
 
                 case HttpStatus.SC_NOT_FOUND:
                     throw new ResourceDoesNotExistException( "File: " + dest + " does not
exist" );
@@ -313,7 +313,7 @@
     /**
      * Converts a String url to an HttpURL
      *
-     * @param url String url to conver to an HttpURL
+     * @param url String url to convert to an HttpURL
      * @return an HttpURL object created from the String url
      * @throws URIException
      */
@@ -393,6 +393,7 @@
         webdavResource.addRequestHeader( "Cache-store", "no-store" );
         webdavResource.addRequestHeader( "Pragma", "no-cache" );
         webdavResource.addRequestHeader( "Expires", "0" );
+        webdavResource.addRequestHeader( "Accept-Encoding", "gzip" );
 
         if ( timestamp > 0 )
         {
@@ -466,7 +467,7 @@
                 return false;
 
             case HttpStatus.SC_FORBIDDEN:
-                throw new AuthorizationException( "Access denided to: " + url );
+                throw new AuthorizationException( "Access denied to: " + url );
 
             case HttpStatus.SC_UNAUTHORIZED:
                 throw new AuthorizationException( "Not authorized." );



---------------------------------------------------------------------
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