diff options
author | Sean Dague | 2007-07-16 15:40:11 +0000 |
---|---|---|
committer | Sean Dague | 2007-07-16 15:40:11 +0000 |
commit | 2a3c79df83e800d5dfe75a1a3b140ed81da2b1d6 (patch) | |
tree | e3f80ad51736cf17e856547b1bcf956010927434 /OpenSim/Framework/Servers/BinaryStreamHandler.cs | |
parent | *Trunk compiles now (diff) | |
download | opensim-SC-2a3c79df83e800d5dfe75a1a3b140ed81da2b1d6.zip opensim-SC-2a3c79df83e800d5dfe75a1a3b140ed81da2b1d6.tar.gz opensim-SC-2a3c79df83e800d5dfe75a1a3b140ed81da2b1d6.tar.bz2 opensim-SC-2a3c79df83e800d5dfe75a1a3b140ed81da2b1d6.tar.xz |
changed to native line ending encoding
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Framework/Servers/BinaryStreamHandler.cs | 98 |
1 files changed, 49 insertions, 49 deletions
diff --git a/OpenSim/Framework/Servers/BinaryStreamHandler.cs b/OpenSim/Framework/Servers/BinaryStreamHandler.cs index 7d4e4ce..6e512f6 100644 --- a/OpenSim/Framework/Servers/BinaryStreamHandler.cs +++ b/OpenSim/Framework/Servers/BinaryStreamHandler.cs | |||
@@ -1,49 +1,49 @@ | |||
1 | using System; | 1 | using System; |
2 | using System.Collections.Generic; | 2 | using System.Collections.Generic; |
3 | using System.Text; | 3 | using System.Text; |
4 | using System.IO; | 4 | 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 | public delegate string BinaryMethod(byte[] data, string path, string param); |
9 | 9 | ||
10 | public class BinaryStreamHandler : BaseStreamHandler | 10 | public class BinaryStreamHandler : BaseStreamHandler |
11 | { | 11 | { |
12 | BinaryMethod m_method; | 12 | BinaryMethod m_method; |
13 | 13 | ||
14 | override public byte[] Handle(string path, Stream request) | 14 | override public byte[] Handle(string path, Stream request) |
15 | { | 15 | { |
16 | byte[] data = ReadFully(request); | 16 | byte[] data = ReadFully(request); |
17 | string param = GetParam(path); | 17 | string param = GetParam(path); |
18 | string responseString = m_method(data, path, param); | 18 | string responseString = m_method(data, path, param); |
19 | 19 | ||
20 | return Encoding.UTF8.GetBytes(responseString); | 20 | return Encoding.UTF8.GetBytes(responseString); |
21 | } | 21 | } |
22 | 22 | ||
23 | public BinaryStreamHandler(string httpMethod, string path, BinaryMethod binaryMethod) | 23 | public BinaryStreamHandler(string httpMethod, string path, BinaryMethod binaryMethod) |
24 | : base(httpMethod, path) | 24 | : base(httpMethod, path) |
25 | { | 25 | { |
26 | m_method = binaryMethod; | 26 | m_method = binaryMethod; |
27 | } | 27 | } |
28 | 28 | ||
29 | private byte[] ReadFully(Stream stream) | 29 | private byte[] ReadFully(Stream stream) |
30 | { | 30 | { |
31 | byte[] buffer = new byte[32768]; | 31 | byte[] buffer = new byte[32768]; |
32 | using (MemoryStream ms = new MemoryStream()) | 32 | using (MemoryStream ms = new MemoryStream()) |
33 | { | 33 | { |
34 | while (true) | 34 | while (true) |
35 | { | 35 | { |
36 | int read = stream.Read(buffer, 0, buffer.Length); | 36 | int read = stream.Read(buffer, 0, buffer.Length); |
37 | 37 | ||
38 | if (read <= 0) | 38 | if (read <= 0) |
39 | { | 39 | { |
40 | return ms.ToArray(); | 40 | return ms.ToArray(); |
41 | } | 41 | } |
42 | 42 | ||
43 | ms.Write(buffer, 0, read); | 43 | ms.Write(buffer, 0, read); |
44 | } | 44 | } |
45 | } | 45 | } |
46 | } | 46 | } |
47 | } | 47 | } |
48 | 48 | ||
49 | } | 49 | } |