diff options
author | James William Dumay <jdumay@apache.org> | 2008-07-03 04:07:35 +0000 |
---|---|---|
committer | James William Dumay <jdumay@apache.org> | 2008-07-03 04:07:35 +0000 |
commit | e66053f72adec0a28f3609e1ef94537e05c3fc66 (patch) | |
tree | 713201b432e945835dad7c609909417695924cb6 | |
parent | 209ad276476cfd53af24203cb2607ea949b73a4e (diff) | |
download | archiva-e66053f72adec0a28f3609e1ef94537e05c3fc66.tar.gz archiva-e66053f72adec0a28f3609e1ef94537e05c3fc66.zip |
MRM-858 - last-modified header is missing
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@673578 13f79535-47bb-0310-9956-ffa450edef68
2 files changed, 21 insertions, 2 deletions
diff --git a/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaDavResourceFactory.java b/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaDavResourceFactory.java index ff34eee1c..5e926ceed 100644 --- a/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaDavResourceFactory.java +++ b/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaDavResourceFactory.java @@ -242,7 +242,7 @@ public class ArchivaDavResourceFactory } else { - setHeaders( locator, response ); + setHeaders(response, locator, resource ); // compatibility with MRM-440 to ensure browsing the repository works ok if ( resource.isCollection() && !request.getRequestURI().endsWith("/" ) ) @@ -556,7 +556,7 @@ public class ArchivaDavResourceFactory this.auditListeners.remove( listener ); } - private void setHeaders( DavResourceLocator locator, DavServletResponse response ) + private void setHeaders( DavServletResponse response, DavResourceLocator locator, DavResource resource ) { // [MRM-503] - Metadata file need Pragma:no-cache response // header. @@ -566,6 +566,9 @@ public class ArchivaDavResourceFactory response.addHeader( "Cache-Control", "no-cache" ); } + //We need to specify this so connecting wagons can work correctly + response.addDateHeader("last-modified", resource.getModificationTime()); + // TODO: [MRM-524] determine http caching options for other types of files (artifacts, sha1, md5, snapshots) } diff --git a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/RepositoryServletNoProxyTest.java b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/RepositoryServletNoProxyTest.java index 2a6d2e40f..b6b0094b3 100644 --- a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/RepositoryServletNoProxyTest.java +++ b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/maven/archiva/webdav/RepositoryServletNoProxyTest.java @@ -35,6 +35,22 @@ import java.io.File; public class RepositoryServletNoProxyTest extends AbstractRepositoryServletTestCase { + public void testLastModifiedHeaderExists() + throws Exception + { + String commonsLangSha1 = "commons-lang/commons-lang/2.1/commons-lang-2.1.jar.sha1"; + + File checksumFile = new File( repoRootInternal, commonsLangSha1 ); + checksumFile.getParentFile().mkdirs(); + + FileUtils.writeStringToFile( checksumFile, "dummy-checksum", null ); + + WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + commonsLangSha1 ); + WebResponse response = sc.getResponse( request ); + + assertNotNull(response.getHeaderField("last-modified")); + } + public void testGetNoProxyChecksumDefaultLayout() throws Exception { |