aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Servers/RestObjectPoster.cs
diff options
context:
space:
mode:
authorMW2007-11-03 14:04:59 +0000
committerMW2007-11-03 14:04:59 +0000
commit91c2c3c096d4d70c7962ef7b9ad4264ca8875ec6 (patch)
tree54704dd438ac513388944c1617463e92c0a7fa0c /OpenSim/Framework/Servers/RestObjectPoster.cs
parentChanges in BulletXPlugin: Added new class BulletXActor class inherits from Ph... (diff)
downloadopensim-SC_OLD-91c2c3c096d4d70c7962ef7b9ad4264ca8875ec6.zip
opensim-SC_OLD-91c2c3c096d4d70c7962ef7b9ad4264ca8875ec6.tar.gz
opensim-SC_OLD-91c2c3c096d4d70c7962ef7b9ad4264ca8875ec6.tar.bz2
opensim-SC_OLD-91c2c3c096d4d70c7962ef7b9ad4264ca8875ec6.tar.xz
testing different rest post method/class for Grid asset client. (possible that I haven't set the post url correctly)
Diffstat (limited to 'OpenSim/Framework/Servers/RestObjectPoster.cs')
-rw-r--r--OpenSim/Framework/Servers/RestObjectPoster.cs49
1 files changed, 49 insertions, 0 deletions
diff --git a/OpenSim/Framework/Servers/RestObjectPoster.cs b/OpenSim/Framework/Servers/RestObjectPoster.cs
new file mode 100644
index 0000000..77660a0
--- /dev/null
+++ b/OpenSim/Framework/Servers/RestObjectPoster.cs
@@ -0,0 +1,49 @@
1using System;
2using System.IO;
3using System.Net;
4using System.Text;
5using System.Xml;
6using System.Xml.Serialization;
7
8
9namespace OpenSim.Framework.Servers
10{
11 public class RestObjectPoster
12 {
13 public static void BeginPostObject<TRequest>(string requestUrl, TRequest obj)
14 {
15 Type type = typeof(TRequest);
16
17 WebRequest request = WebRequest.Create(requestUrl);
18 request.Method = "POST";
19 request.ContentType = "text/xml";
20
21 MemoryStream buffer = new MemoryStream();
22
23 XmlWriterSettings settings = new XmlWriterSettings();
24 settings.Encoding = Encoding.UTF8;
25
26 using (XmlWriter writer = XmlWriter.Create(buffer, settings))
27 {
28 XmlSerializer serializer = new XmlSerializer(type);
29 serializer.Serialize(writer, obj);
30 writer.Flush();
31 }
32
33 int length = (int)buffer.Length;
34 request.ContentLength = length;
35
36 Stream requestStream = request.GetRequestStream();
37 requestStream.Write(buffer.ToArray(), 0, length);
38 IAsyncResult result = request.BeginGetResponse(AsyncCallback, request);
39 }
40
41 private static void AsyncCallback(IAsyncResult result)
42 {
43 WebRequest request = (WebRequest)result.AsyncState;
44 using (WebResponse resp = request.EndGetResponse(result))
45 {
46 }
47 }
48 }
49} \ No newline at end of file