From c74f7ea2b9f6359b74e8dc9777f83e8decafec2e Mon Sep 17 00:00:00 2001 From: James William Dumay Date: Tue, 8 Jul 2008 01:28:19 +0000 Subject: [PATCH] MRM-867 - 500 on HTTP HEAD git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@674698 13f79535-47bb-0310-9956-ffa450edef68 --- .../archiva/webdav/ArchivaDavResource.java | 13 +++++++----- .../webdav/ArchivaVirtualDavResource.java | 21 +++++++++++-------- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaDavResource.java b/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaDavResource.java index 0aadb3c73..0472b7f68 100644 --- a/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaDavResource.java +++ b/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaDavResource.java @@ -183,14 +183,17 @@ public class ArchivaDavResource public void spool( OutputContext outputContext ) throws IOException { - if ( !isCollection() ) + if ( !isCollection()) + { + outputContext.setContentLength( localResource.length() ); + outputContext.setContentType( mimeTypes.getMimeType( localResource.getName() ) ); + } + + if ( !isCollection() && outputContext.hasStream() ) { FileInputStream is = null; try { - outputContext.setContentLength( localResource.length() ); - outputContext.setContentType( mimeTypes.getMimeType( localResource.getName() ) ); - // Write content to stream is = new FileInputStream( localResource ); IOUtils.copy( is, outputContext.getOutputStream() ); @@ -200,7 +203,7 @@ public class ArchivaDavResource IOUtils.closeQuietly( is ); } } - else + else if (outputContext.hasStream()) { IndexWriter writer = new IndexWriter( this, localResource, logicalResource ); writer.write( outputContext ); diff --git a/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaVirtualDavResource.java b/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaVirtualDavResource.java index af671f587..f5ada0b72 100644 --- a/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaVirtualDavResource.java +++ b/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaVirtualDavResource.java @@ -94,19 +94,22 @@ public class ArchivaVirtualDavResource public void spool( OutputContext outputContext ) throws IOException { - Collections.sort( localResources ); - List localResourceFiles = new ArrayList(); - - for ( File resourceFile : localResources ) + if (outputContext.hasStream()) { - if ( resourceFile.exists() ) + Collections.sort( localResources ); + List localResourceFiles = new ArrayList(); + + for ( File resourceFile : localResources ) { - localResourceFiles.add( resourceFile ); + if ( resourceFile.exists() ) + { + localResourceFiles.add( resourceFile ); + } } - } - IndexWriter writer = new IndexWriter( this, localResourceFiles, logicalResource ); - writer.write( outputContext ); + IndexWriter writer = new IndexWriter( this, localResourceFiles, logicalResource ); + writer.write( outputContext ); + } } public void addLockManager( LockManager arg0 ) -- 2.39.5