http server useless changes
parent
0d940df4e2
commit
7ce9f890b1
|
@ -47,30 +47,23 @@ namespace OpenSim.Framework.Servers.HttpServer
|
||||||
|
|
||||||
protected override byte[] ProcessRequest(string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
|
protected override byte[] ProcessRequest(string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
|
||||||
{
|
{
|
||||||
byte[] data = ReadFully(request);
|
byte[] data;
|
||||||
|
if (request is MemoryStream)
|
||||||
|
data = ((MemoryStream)request).ToArray();
|
||||||
|
else
|
||||||
|
{
|
||||||
|
request.Seek(0, SeekOrigin.Begin);
|
||||||
|
using (MemoryStream ms = new MemoryStream((int)request.Length))
|
||||||
|
{
|
||||||
|
request.CopyTo(ms);
|
||||||
|
data = ms.ToArray();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
request.Dispose();
|
||||||
|
|
||||||
string param = GetParam(path);
|
string param = GetParam(path);
|
||||||
string responseString = m_method(data, path, param);
|
string responseString = m_method(data, path, param);
|
||||||
|
|
||||||
return Encoding.UTF8.GetBytes(responseString);
|
return Encoding.UTF8.GetBytes(responseString);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static byte[] ReadFully(Stream stream)
|
|
||||||
{
|
|
||||||
byte[] buffer = new byte[1024];
|
|
||||||
using (MemoryStream ms = new MemoryStream(1024*256))
|
|
||||||
{
|
|
||||||
while (true)
|
|
||||||
{
|
|
||||||
int read = stream.Read(buffer, 0, buffer.Length);
|
|
||||||
|
|
||||||
if (read <= 0)
|
|
||||||
{
|
|
||||||
return ms.ToArray();
|
|
||||||
}
|
|
||||||
|
|
||||||
ms.Write(buffer, 0, read);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue