diff options
* Moved SendNameReply to ClientView
* Removed unused LoginService
* Minor renames on BinaryStreamHandler
Diffstat (limited to 'OpenSim/Framework/Servers/BinaryStreamHandler.cs')
-rw-r--r-- | OpenSim/Framework/Servers/BinaryStreamHandler.cs | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/OpenSim/Framework/Servers/BinaryStreamHandler.cs b/OpenSim/Framework/Servers/BinaryStreamHandler.cs index 302dbff..7d4e4ce 100644 --- a/OpenSim/Framework/Servers/BinaryStreamHandler.cs +++ b/OpenSim/Framework/Servers/BinaryStreamHandler.cs | |||
@@ -5,27 +5,28 @@ using System.IO; | |||
5 | 5 | ||
6 | namespace OpenSim.Framework.Servers | 6 | namespace OpenSim.Framework.Servers |
7 | { | 7 | { |
8 | public delegate string BinaryMethod(byte[] data, string path, string param); | ||
8 | 9 | ||
9 | public class BinaryStreamHandler : BaseStreamHandler | 10 | public class BinaryStreamHandler : BaseStreamHandler |
10 | { | 11 | { |
11 | BinaryMethod m_restMethod; | 12 | BinaryMethod m_method; |
12 | 13 | ||
13 | override public byte[] Handle(string path, Stream request) | 14 | override public byte[] Handle(string path, Stream request) |
14 | { | 15 | { |
15 | byte[] data = ReadFully(request); | 16 | byte[] data = ReadFully(request); |
16 | string param = GetParam(path); | 17 | string param = GetParam(path); |
17 | string responseString = m_restMethod(data, path, param); | 18 | string responseString = m_method(data, path, param); |
18 | 19 | ||
19 | return Encoding.UTF8.GetBytes(responseString); | 20 | return Encoding.UTF8.GetBytes(responseString); |
20 | } | 21 | } |
21 | 22 | ||
22 | public BinaryStreamHandler(string httpMethod, string path, BinaryMethod restMethod) | 23 | public BinaryStreamHandler(string httpMethod, string path, BinaryMethod binaryMethod) |
23 | : base(httpMethod, path) | 24 | : base(httpMethod, path) |
24 | { | 25 | { |
25 | m_restMethod = restMethod; | 26 | m_method = binaryMethod; |
26 | } | 27 | } |
27 | 28 | ||
28 | public byte[] ReadFully(Stream stream) | 29 | private byte[] ReadFully(Stream stream) |
29 | { | 30 | { |
30 | byte[] buffer = new byte[32768]; | 31 | byte[] buffer = new byte[32768]; |
31 | using (MemoryStream ms = new MemoryStream()) | 32 | using (MemoryStream ms = new MemoryStream()) |
@@ -33,11 +34,15 @@ namespace OpenSim.Framework.Servers | |||
33 | while (true) | 34 | while (true) |
34 | { | 35 | { |
35 | int read = stream.Read(buffer, 0, buffer.Length); | 36 | int read = stream.Read(buffer, 0, buffer.Length); |
37 | |||
36 | if (read <= 0) | 38 | if (read <= 0) |
39 | { | ||
37 | return ms.ToArray(); | 40 | return ms.ToArray(); |
41 | } | ||
42 | |||
38 | ms.Write(buffer, 0, read); | 43 | ms.Write(buffer, 0, read); |
39 | } | 44 | } |
40 | } | 45 | } |
41 | } | 46 | } |
42 | } | 47 | } |
43 | 48 | ||