[MRM-165] add HTTP headers

git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/trunk@451600 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Brett Porter 2006-09-30 13:51:38 +00:00
parent 2fcc81f5c8
commit 8fe4a8ab7b
2 changed files with 24 additions and 0 deletions

View File

@ -26,6 +26,10 @@ import java.io.FileInputStream;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.io.InputStream; import java.io.InputStream;
import com.opensymphony.webwork.interceptor.ServletResponseAware;
import javax.servlet.http.HttpServletResponse;
/** /**
* Proxy functionality. * Proxy functionality.
* *
@ -33,6 +37,7 @@ import java.io.InputStream;
*/ */
public class ProxyAction public class ProxyAction
extends PlexusActionSupport extends PlexusActionSupport
implements ServletResponseAware
{ {
/** /**
* @plexus.requirement * @plexus.requirement
@ -49,6 +54,10 @@ public class ProxyAction
private InputStream artifactStream; private InputStream artifactStream;
private long contentLength;
private HttpServletResponse httpServletResponse;
public String execute() public String execute()
throws ProxyException throws ProxyException
{ {
@ -62,6 +71,10 @@ public class ProxyAction
contentType = "application/octet-stream"; contentType = "application/octet-stream";
filename = file.getName(); filename = file.getName();
contentLength = file.length();
httpServletResponse.addDateHeader( "Last-Modified", file.lastModified() );
} }
catch ( ResourceDoesNotExistException e ) catch ( ResourceDoesNotExistException e )
{ {
@ -99,8 +112,18 @@ public class ProxyAction
return contentType; return contentType;
} }
public long getContentLength()
{
return contentLength;
}
public InputStream getArtifactStream() public InputStream getArtifactStream()
{ {
return artifactStream; return artifactStream;
} }
public void setServletResponse( HttpServletResponse httpServletResponse )
{
this.httpServletResponse = httpServletResponse;
}
} }

View File

@ -176,6 +176,7 @@
<param name="contentDisposition">filename="${filename}"</param> <param name="contentDisposition">filename="${filename}"</param>
<param name="inputName">artifactStream</param> <param name="inputName">artifactStream</param>
<param name="bufferSize">1024</param> <param name="bufferSize">1024</param>
<param name="contentLength">${contentLength}</param>
</result> </result>
<result name="notFound" type="httpheader">404</result> <result name="notFound" type="httpheader">404</result>
</action> </action>