diff options
Diffstat (limited to 'OpenSim/Framework/Servers/RestStreamHandler.cs')
-rw-r--r-- | OpenSim/Framework/Servers/RestStreamHandler.cs | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/OpenSim/Framework/Servers/RestStreamHandler.cs b/OpenSim/Framework/Servers/RestStreamHandler.cs new file mode 100644 index 0000000..1b3b41c --- /dev/null +++ b/OpenSim/Framework/Servers/RestStreamHandler.cs | |||
@@ -0,0 +1,31 @@ | |||
1 | using System; | ||
2 | using System.Collections.Generic; | ||
3 | using System.Text; | ||
4 | using System.IO; | ||
5 | |||
6 | namespace OpenSim.Framework.Servers | ||
7 | { | ||
8 | public class RestStreamHandler : BaseStreamHandler | ||
9 | { | ||
10 | RestMethod m_restMethod; | ||
11 | |||
12 | override public byte[] Handle(string path, Stream request ) | ||
13 | { | ||
14 | Encoding encoding = Encoding.UTF8; | ||
15 | StreamReader streamReader = new StreamReader(request, encoding); | ||
16 | |||
17 | string requestBody = streamReader.ReadToEnd(); | ||
18 | streamReader.Close(); | ||
19 | |||
20 | string param = GetParam(path); | ||
21 | string responseString = m_restMethod(requestBody, path, param ); | ||
22 | |||
23 | return Encoding.UTF8.GetBytes(responseString); | ||
24 | } | ||
25 | |||
26 | public RestStreamHandler(string httpMethod, string path, RestMethod restMethod) : base( httpMethod, path ) | ||
27 | { | ||
28 | m_restMethod = restMethod; | ||
29 | } | ||
30 | } | ||
31 | } | ||