aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Servers/RestStreamHandler.cs
blob: 7ca369d3987436ae6c35013950c4534a2b7ce388 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;

namespace OpenSim.Framework.Servers
{
    public class RestStreamHandler : BaseStreamHandler
    {
        RestMethod m_restMethod;

        override public byte[] Handle(string path, Stream request )
        {
            Encoding encoding = Encoding.UTF8;
            StreamReader streamReader = new StreamReader(request, encoding);

            string requestBody = streamReader.ReadToEnd();
            streamReader.Close();

            string param = GetParam(path);
            string responseString = m_restMethod(requestBody, path, param );

            return Encoding.UTF8.GetBytes(responseString);
        }

        public RestStreamHandler(string httpMethod, string path, RestMethod restMethod) : base( path, httpMethod )
        {
            m_restMethod = restMethod;
        }
    }
}