aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Servers
diff options
context:
space:
mode:
authorJeff Ames2007-11-04 14:34:45 +0000
committerJeff Ames2007-11-04 14:34:45 +0000
commit2d1c255e8c427c8c595be455e6d7f5c4e01c99a6 (patch)
treea95f2a5085505192293603f8b0c9df23c4ac7041 /OpenSim/Framework/Servers
parentApplying Teravus patch # 557. Some glue code for the updating of prim's veloc... (diff)
downloadopensim-SC_OLD-2d1c255e8c427c8c595be455e6d7f5c4e01c99a6.zip
opensim-SC_OLD-2d1c255e8c427c8c595be455e6d7f5c4e01c99a6.tar.gz
opensim-SC_OLD-2d1c255e8c427c8c595be455e6d7f5c4e01c99a6.tar.bz2
opensim-SC_OLD-2d1c255e8c427c8c595be455e6d7f5c4e01c99a6.tar.xz
normalized line endings
Diffstat (limited to 'OpenSim/Framework/Servers')
-rw-r--r--OpenSim/Framework/Servers/BaseRequestHandler.cs68
-rw-r--r--OpenSim/Framework/Servers/RestDeserialiseHandler.cs74
-rw-r--r--OpenSim/Framework/Servers/RestObjectPoster.cs96
3 files changed, 119 insertions, 119 deletions
diff --git a/OpenSim/Framework/Servers/BaseRequestHandler.cs b/OpenSim/Framework/Servers/BaseRequestHandler.cs
index b357763..155a283 100644
--- a/OpenSim/Framework/Servers/BaseRequestHandler.cs
+++ b/OpenSim/Framework/Servers/BaseRequestHandler.cs
@@ -1,35 +1,35 @@
1namespace OpenSim.Framework.Servers 1namespace OpenSim.Framework.Servers
2{ 2{
3 public class BaseRequestHandler 3 public class BaseRequestHandler
4 { 4 {
5 public virtual string ContentType 5 public virtual string ContentType
6 { 6 {
7 get { return "application/xml"; } 7 get { return "application/xml"; }
8 } 8 }
9 9
10 private readonly string m_httpMethod; 10 private readonly string m_httpMethod;
11 11
12 public virtual string HttpMethod 12 public virtual string HttpMethod
13 { 13 {
14 get { return m_httpMethod; } 14 get { return m_httpMethod; }
15 } 15 }
16 16
17 private readonly string m_path; 17 private readonly string m_path;
18 18
19 protected BaseRequestHandler(string httpMethod, string path) 19 protected BaseRequestHandler(string httpMethod, string path)
20 { 20 {
21 m_httpMethod = httpMethod; 21 m_httpMethod = httpMethod;
22 m_path = path; 22 m_path = path;
23 } 23 }
24 24
25 public virtual string Path 25 public virtual string Path
26 { 26 {
27 get { return m_path; } 27 get { return m_path; }
28 } 28 }
29 29
30 protected string GetParam(string path) 30 protected string GetParam(string path)
31 { 31 {
32 return path.Substring(m_path.Length); 32 return path.Substring(m_path.Length);
33 } 33 }
34 } 34 }
35} \ No newline at end of file 35} \ No newline at end of file
diff --git a/OpenSim/Framework/Servers/RestDeserialiseHandler.cs b/OpenSim/Framework/Servers/RestDeserialiseHandler.cs
index adf5c3f..a47d3d3 100644
--- a/OpenSim/Framework/Servers/RestDeserialiseHandler.cs
+++ b/OpenSim/Framework/Servers/RestDeserialiseHandler.cs
@@ -1,38 +1,38 @@
1using System.IO; 1using System.IO;
2using System.Xml; 2using System.Xml;
3using System.Xml.Serialization; 3using System.Xml.Serialization;
4 4
5namespace OpenSim.Framework.Servers 5namespace OpenSim.Framework.Servers
6{ 6{
7 public delegate TResponse RestDeserialiseMethod<TRequest, TResponse>(TRequest request); 7 public delegate TResponse RestDeserialiseMethod<TRequest, TResponse>(TRequest request);
8 8
9 public class RestDeserialisehandler<TRequest, TResponse> : BaseRequestHandler, IStreamHandler 9 public class RestDeserialisehandler<TRequest, TResponse> : BaseRequestHandler, IStreamHandler
10 where TRequest : new() 10 where TRequest : new()
11 { 11 {
12 private RestDeserialiseMethod<TRequest, TResponse> m_method; 12 private RestDeserialiseMethod<TRequest, TResponse> m_method;
13 13
14 public RestDeserialisehandler(string httpMethod, string path, RestDeserialiseMethod<TRequest, TResponse> method) 14 public RestDeserialisehandler(string httpMethod, string path, RestDeserialiseMethod<TRequest, TResponse> method)
15 : base(httpMethod, path) 15 : base(httpMethod, path)
16 { 16 {
17 m_method = method; 17 m_method = method;
18 } 18 }
19 19
20 public void Handle(string path, Stream request, Stream responseStream) 20 public void Handle(string path, Stream request, Stream responseStream)
21 { 21 {
22 TRequest deserial; 22 TRequest deserial;
23 using (XmlTextReader xmlReader = new XmlTextReader(request)) 23 using (XmlTextReader xmlReader = new XmlTextReader(request))
24 { 24 {
25 XmlSerializer deserializer = new XmlSerializer(typeof (TRequest)); 25 XmlSerializer deserializer = new XmlSerializer(typeof (TRequest));
26 deserial = (TRequest) deserializer.Deserialize(xmlReader); 26 deserial = (TRequest) deserializer.Deserialize(xmlReader);
27 } 27 }
28 28
29 TResponse response = m_method(deserial); 29 TResponse response = m_method(deserial);
30 30
31 using (XmlWriter xmlWriter = XmlTextWriter.Create(responseStream)) 31 using (XmlWriter xmlWriter = XmlTextWriter.Create(responseStream))
32 { 32 {
33 XmlSerializer serializer = new XmlSerializer(typeof (TResponse)); 33 XmlSerializer serializer = new XmlSerializer(typeof (TResponse));
34 serializer.Serialize(xmlWriter, response); 34 serializer.Serialize(xmlWriter, response);
35 } 35 }
36 } 36 }
37 } 37 }
38} \ No newline at end of file 38} \ No newline at end of file
diff --git a/OpenSim/Framework/Servers/RestObjectPoster.cs b/OpenSim/Framework/Servers/RestObjectPoster.cs
index 77660a0..b77cbcc 100644
--- a/OpenSim/Framework/Servers/RestObjectPoster.cs
+++ b/OpenSim/Framework/Servers/RestObjectPoster.cs
@@ -1,49 +1,49 @@
1using System; 1using System;
2using System.IO; 2using System.IO;
3using System.Net; 3using System.Net;
4using System.Text; 4using System.Text;
5using System.Xml; 5using System.Xml;
6using System.Xml.Serialization; 6using System.Xml.Serialization;
7 7
8 8
9namespace OpenSim.Framework.Servers 9namespace OpenSim.Framework.Servers
10{ 10{
11 public class RestObjectPoster 11 public class RestObjectPoster
12 { 12 {
13 public static void BeginPostObject<TRequest>(string requestUrl, TRequest obj) 13 public static void BeginPostObject<TRequest>(string requestUrl, TRequest obj)
14 { 14 {
15 Type type = typeof(TRequest); 15 Type type = typeof(TRequest);
16 16
17 WebRequest request = WebRequest.Create(requestUrl); 17 WebRequest request = WebRequest.Create(requestUrl);
18 request.Method = "POST"; 18 request.Method = "POST";
19 request.ContentType = "text/xml"; 19 request.ContentType = "text/xml";
20 20
21 MemoryStream buffer = new MemoryStream(); 21 MemoryStream buffer = new MemoryStream();
22 22
23 XmlWriterSettings settings = new XmlWriterSettings(); 23 XmlWriterSettings settings = new XmlWriterSettings();
24 settings.Encoding = Encoding.UTF8; 24 settings.Encoding = Encoding.UTF8;
25 25
26 using (XmlWriter writer = XmlWriter.Create(buffer, settings)) 26 using (XmlWriter writer = XmlWriter.Create(buffer, settings))
27 { 27 {
28 XmlSerializer serializer = new XmlSerializer(type); 28 XmlSerializer serializer = new XmlSerializer(type);
29 serializer.Serialize(writer, obj); 29 serializer.Serialize(writer, obj);
30 writer.Flush(); 30 writer.Flush();
31 } 31 }
32 32
33 int length = (int)buffer.Length; 33 int length = (int)buffer.Length;
34 request.ContentLength = length; 34 request.ContentLength = length;
35 35
36 Stream requestStream = request.GetRequestStream(); 36 Stream requestStream = request.GetRequestStream();
37 requestStream.Write(buffer.ToArray(), 0, length); 37 requestStream.Write(buffer.ToArray(), 0, length);
38 IAsyncResult result = request.BeginGetResponse(AsyncCallback, request); 38 IAsyncResult result = request.BeginGetResponse(AsyncCallback, request);
39 } 39 }
40 40
41 private static void AsyncCallback(IAsyncResult result) 41 private static void AsyncCallback(IAsyncResult result)
42 { 42 {
43 WebRequest request = (WebRequest)result.AsyncState; 43 WebRequest request = (WebRequest)result.AsyncState;
44 using (WebResponse resp = request.EndGetResponse(result)) 44 using (WebResponse resp = request.EndGetResponse(result))
45 { 45 {
46 } 46 }
47 } 47 }
48 } 48 }
49} \ No newline at end of file 49} \ No newline at end of file