[MRM-1356] handle chunked / unknown length requests correctly

git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@919307 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Brett Porter 2010-03-05 06:09:53 +00:00
parent cf3593554a
commit e521a959c5
1 changed files with 7 additions and 4 deletions

View File

@ -303,13 +303,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 );
}