From 8cf166a1844c185b18ebb87213aff3cf1c5d6f8d Mon Sep 17 00:00:00 2001 From: Brett Porter Date: Fri, 5 Mar 2010 06:42:52 +0000 Subject: [PATCH] [MRM-1356] handle chunked / unknown length requests correctly Merged from: r919307 git-svn-id: https://svn.apache.org/repos/asf/archiva/branches/archiva-1.3.x@919313 13f79535-47bb-0310-9956-ffa450edef68 --- .../maven/archiva/webdav/ArchivaDavResource.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 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 0b0401009..d08a3700d 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 @@ -310,13 +310,16 @@ public class ArchivaDavResource } // TODO: a bad deployment shouldn't delete an existing file - do we need to write to a temporary location first? - if ( inputContext.getContentLength() != localFile.length() ) + long expectedContentLength = inputContext.getContentLength(); + long actualContentLength = localFile.length(); + // length of -1 is given for a chunked request or unknown length, in which case we accept what was uploaded + if ( expectedContentLength >= 0 && expectedContentLength != actualContentLength ) { - FileUtils.deleteQuietly( localFile ); - String msg = - "Content Header length was " + inputContext.getContentLength() + " but was " + localFile.length(); + "Content Header length was " + expectedContentLength + " but was " + actualContentLength; log.debug( "Upload failed: " + msg ); + + FileUtils.deleteQuietly( localFile ); throw new DavException( HttpServletResponse.SC_BAD_REQUEST, msg ); } -- 2.39.5