From 7ce9f890b127b9cfcea3694c372c9a1e188c3bc4 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sat, 11 Apr 2020 16:41:39 +0100 Subject: [PATCH] http server useless changes --- .../Servers/HttpServer/BinaryStreamHandler.cs | 33 ++++++++----------- 1 file changed, 13 insertions(+), 20 deletions(-) diff --git a/OpenSim/Framework/Servers/HttpServer/BinaryStreamHandler.cs b/OpenSim/Framework/Servers/HttpServer/BinaryStreamHandler.cs index 1b03f543d3..de5f701f52 100644 --- a/OpenSim/Framework/Servers/HttpServer/BinaryStreamHandler.cs +++ b/OpenSim/Framework/Servers/HttpServer/BinaryStreamHandler.cs @@ -47,30 +47,23 @@ namespace OpenSim.Framework.Servers.HttpServer protected override byte[] ProcessRequest(string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) { - byte[] data = ReadFully(request); - string param = GetParam(path); - string responseString = m_method(data, path, param); - - return Encoding.UTF8.GetBytes(responseString); - } - - private static byte[] ReadFully(Stream stream) - { - byte[] buffer = new byte[1024]; - using (MemoryStream ms = new MemoryStream(1024*256)) + byte[] data; + if (request is MemoryStream) + data = ((MemoryStream)request).ToArray(); + else { - while (true) + request.Seek(0, SeekOrigin.Begin); + using (MemoryStream ms = new MemoryStream((int)request.Length)) { - int read = stream.Read(buffer, 0, buffer.Length); - - if (read <= 0) - { - return ms.ToArray(); - } - - ms.Write(buffer, 0, read); + request.CopyTo(ms); + data = ms.ToArray(); } } + request.Dispose(); + + string param = GetParam(path); + string responseString = m_method(data, path, param); + return Encoding.UTF8.GetBytes(responseString); } } } \ No newline at end of file