]> source.dussan.org Git - archiva.git/commitdiff
[MRM-165] add HTTP headers
authorBrett Porter <brett@apache.org>
Sat, 30 Sep 2006 13:51:38 +0000 (13:51 +0000)
committerBrett Porter <brett@apache.org>
Sat, 30 Sep 2006 13:51:38 +0000 (13:51 +0000)
git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/trunk@451600 13f79535-47bb-0310-9956-ffa450edef68

archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/ProxyAction.java
archiva-webapp/src/main/resources/xwork.xml

index b75a2a97a1928c2d3fff76f183f16c26ab533950..10a6945ee9fbbe44283240ad81700f0cdca7df4c 100644 (file)
@@ -26,6 +26,10 @@ import java.io.FileInputStream;
 import java.io.FileNotFoundException;
 import java.io.InputStream;
 
+import com.opensymphony.webwork.interceptor.ServletResponseAware;
+
+import javax.servlet.http.HttpServletResponse;
+
 /**
  * Proxy functionality.
  *
@@ -33,6 +37,7 @@ import java.io.InputStream;
  */
 public class ProxyAction
     extends PlexusActionSupport
+    implements ServletResponseAware
 {
     /**
      * @plexus.requirement
@@ -49,6 +54,10 @@ public class ProxyAction
 
     private InputStream artifactStream;
 
+    private long contentLength;
+
+    private HttpServletResponse httpServletResponse;
+
     public String execute()
         throws ProxyException
     {
@@ -62,6 +71,10 @@ public class ProxyAction
             contentType = "application/octet-stream";
 
             filename = file.getName();
+
+            contentLength = file.length();
+
+            httpServletResponse.addDateHeader( "Last-Modified", file.lastModified() );
         }
         catch ( ResourceDoesNotExistException e )
         {
@@ -99,8 +112,18 @@ public class ProxyAction
         return contentType;
     }
 
+    public long getContentLength()
+    {
+        return contentLength;
+    }
+
     public InputStream getArtifactStream()
     {
         return artifactStream;
     }
+
+    public void setServletResponse( HttpServletResponse httpServletResponse )
+    {
+        this.httpServletResponse = httpServletResponse;
+    }
 }
index fa2c9a8d01a7354a0cd26a0a7c5b0599b4bc50a2..35ac7aa938ff783237c4549ee682bef724b7c045 100644 (file)
         <param name="contentDisposition">filename="${filename}"</param>
         <param name="inputName">artifactStream</param>
         <param name="bufferSize">1024</param>
+        <param name="contentLength">${contentLength}</param>
       </result>
       <result name="notFound" type="httpheader">404</result>
     </action>