From aaaa4de752c028abd952f83777bf0daf6abf8c54 Mon Sep 17 00:00:00 2001 From: Michael Becker Date: Tue, 29 Oct 2019 19:58:05 -0400 Subject: [PATCH] holy shit this actually works now --- .../Accessors/HTTPAccessor.cs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/CSharp/Plugins/UniversalEditor.Plugins.Web/Accessors/HTTPAccessor.cs b/CSharp/Plugins/UniversalEditor.Plugins.Web/Accessors/HTTPAccessor.cs index 5ade42bb..53315e08 100644 --- a/CSharp/Plugins/UniversalEditor.Plugins.Web/Accessors/HTTPAccessor.cs +++ b/CSharp/Plugins/UniversalEditor.Plugins.Web/Accessors/HTTPAccessor.cs @@ -123,13 +123,17 @@ namespace UniversalEditor.Accessors // total count of bytes to be read from both buffer and stream long realCount = bufferCount + newCount; - byte[] newBuffer = new byte[newCount]; - int readFromStream = mvarStream.Read(newBuffer, 0, (int)newCount); - - Array.Copy(newBuffer, 0, mvarBuffer, (int)(start + bufferCount), newCount); + if (newCount > 0) + { + byte[] newBuffer = new byte[newCount]; + int readFromStream = mvarStream.Read(newBuffer, 0, (int)newCount); + Array.Copy(newBuffer, 0, mvarBuffer, (int)(start + bufferCount), newCount); + } Array.Copy(mvarBuffer, mvarPosition, buffer, start, realCount); + mvarActualPosition += newCount; + mvarPosition += count; return (int)realCount; } else if (mvarPosition == mvarActualPosition)