diff options
author | lbsa71 | 2007-07-04 11:47:32 +0000 |
---|---|---|
committer | lbsa71 | 2007-07-04 11:47:32 +0000 |
commit | 9a51949cb4c833dcacf2a5803a8f2753273941c8 (patch) | |
tree | 698f58d78bc8bc20b3d82c7683723fe2c9eacca7 /OpenSim/Framework/Servers/RestStreamHandler.cs | |
parent | Grid Servers: (diff) | |
download | opensim-SC_OLD-9a51949cb4c833dcacf2a5803a8f2753273941c8.zip opensim-SC_OLD-9a51949cb4c833dcacf2a5803a8f2753273941c8.tar.gz opensim-SC_OLD-9a51949cb4c833dcacf2a5803a8f2753273941c8.tar.bz2 opensim-SC_OLD-9a51949cb4c833dcacf2a5803a8f2753273941c8.tar.xz |
* Added StreamHandler support
* Implemented RestStreamHandler
* Some caps functions now use it
* Moved out RestMethodEntry from httpserver
* The IStreamHandler interface now reports required method and Content-Type
Diffstat (limited to 'OpenSim/Framework/Servers/RestStreamHandler.cs')
-rw-r--r-- | OpenSim/Framework/Servers/RestStreamHandler.cs | 34 |
1 files changed, 32 insertions, 2 deletions
diff --git a/OpenSim/Framework/Servers/RestStreamHandler.cs b/OpenSim/Framework/Servers/RestStreamHandler.cs index 145a184..64d6ea3 100644 --- a/OpenSim/Framework/Servers/RestStreamHandler.cs +++ b/OpenSim/Framework/Servers/RestStreamHandler.cs | |||
@@ -7,9 +7,39 @@ namespace OpenSim.Framework.Servers | |||
7 | { | 7 | { |
8 | public class RestStreamHandler : IStreamHandler | 8 | public class RestStreamHandler : IStreamHandler |
9 | { | 9 | { |
10 | public void Handle( string path, Stream request, Stream response ) | 10 | RestMethod m_restMethod; |
11 | |||
12 | private string m_contentType; | ||
13 | public string ContentType | ||
14 | { | ||
15 | get { return m_contentType; } | ||
16 | } | ||
17 | |||
18 | private string m_httpMethod; | ||
19 | public string HttpMethod | ||
20 | { | ||
21 | get { return m_httpMethod; } | ||
22 | } | ||
23 | |||
24 | |||
25 | public byte[] Handle(string path, Stream request ) | ||
26 | { | ||
27 | Encoding encoding = Encoding.UTF8; | ||
28 | StreamReader reader = new StreamReader(request, encoding); | ||
29 | |||
30 | string requestBody = reader.ReadToEnd(); | ||
31 | reader.Close(); | ||
32 | |||
33 | string responseString = m_restMethod(requestBody, path, m_httpMethod); | ||
34 | |||
35 | return Encoding.UTF8.GetBytes(responseString); | ||
36 | } | ||
37 | |||
38 | public RestStreamHandler(RestMethod restMethod, string httpMethod, string contentType) | ||
11 | { | 39 | { |
12 | 40 | m_restMethod = restMethod; | |
41 | m_httpMethod = httpMethod; | ||
42 | m_contentType = contentType; | ||
13 | } | 43 | } |
14 | } | 44 | } |
15 | } | 45 | } |