From 8e4870b551183654438cc9b3066967d814178ec2 Mon Sep 17 00:00:00 2001 From: Kevin Wang Date: Tue, 5 Nov 2013 21:08:22 -0500 Subject: [PATCH] HPCC-10301 Read enough data for mime header process when uploading files When uploading files, a data buffer is used to process the file data (1k) block by block. After one file is read, a part of file data for the next file is left inside the data buffer. If the data does not contain all of the mime headers for the file, the file data cannot be treated properly. This fix checks the data size in the data buffer. If the data buffer has less than 512 bytes, then I append the next 1K block to the data buffer before processing. Signed-off-by: Kevin Wang kevin.wang@lexisnexis.com --- esp/bindings/http/platform/httptransport.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/esp/bindings/http/platform/httptransport.cpp b/esp/bindings/http/platform/httptransport.cpp index 9ade5a46302..8c97e4600b3 100644 --- a/esp/bindings/http/platform/httptransport.cpp +++ b/esp/bindings/http/platform/httptransport.cpp @@ -1848,7 +1848,9 @@ bool CHttpRequest::readContentToBuffer(MemoryBuffer& buffer, __int64& bytesNotRe bool CHttpRequest::readUploadFileName(CMimeMultiPart* mimemultipart, StringBuffer& fileName, MemoryBuffer& contentBuffer, __int64& bytesNotRead) { - if (contentBuffer.length()) + //Make sure that contentBuffer contains all of the mime headers for a file. The readUploadFileName() retrieves + //the file name from those headers and moves a data pointer to the end of those headers. + if ((bytesNotRead < 1) || (contentBuffer.length() > 512)) mimemultipart->readUploadFileName(contentBuffer, fileName); while((fileName.length() < 1) && (bytesNotRead > 0))