aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Framework/Communications/Cache/GridAssetClient.cs22
-rw-r--r--OpenSim/Framework/Servers/RestObjectPoster.cs49
2 files changed, 61 insertions, 10 deletions
diff --git a/OpenSim/Framework/Communications/Cache/GridAssetClient.cs b/OpenSim/Framework/Communications/Cache/GridAssetClient.cs
index 64e561b..632f96c 100644
--- a/OpenSim/Framework/Communications/Cache/GridAssetClient.cs
+++ b/OpenSim/Framework/Communications/Cache/GridAssetClient.cs
@@ -32,6 +32,7 @@ using System.IO;
32using System.Xml.Serialization; 32using System.Xml.Serialization;
33using libsecondlife; 33using libsecondlife;
34using OpenSim.Framework.Console; 34using OpenSim.Framework.Console;
35using OpenSim.Framework.Servers;
35 36
36namespace OpenSim.Framework.Communications.Cache 37namespace OpenSim.Framework.Communications.Cache
37{ 38{
@@ -103,16 +104,17 @@ namespace OpenSim.Framework.Communications.Cache
103 { 104 {
104 try 105 try
105 { 106 {
106 MemoryStream s = new MemoryStream(); 107 // MemoryStream s = new MemoryStream();
107 108
108 XmlSerializer xs = new XmlSerializer(typeof (AssetBase)); 109 // XmlSerializer xs = new XmlSerializer(typeof(AssetBase));
109 xs.Serialize(s, asset); 110 // xs.Serialize(s, asset);
110 RestClient rc = new RestClient(_assetServerUrl); 111 // RestClient rc = new RestClient(_assetServerUrl);
111 MainLog.Instance.Verbose("ASSET", "Storing {0}", rc); 112 MainLog.Instance.Verbose("ASSET", "Storing asset");
112 rc.AddResourcePath("assets"); 113 //rc.AddResourcePath("assets");
113 rc.RequestMethod = "POST"; 114 // rc.RequestMethod = "POST";
114 rc.Request(s); 115 // rc.Request(s);
115 MainLog.Instance.Verbose("ASSET", "Stored {0}", rc); 116 //MainLog.Instance.Verbose("ASSET", "Stored {0}", rc);
117 RestObjectPoster.BeginPostObject<AssetBase>(_assetRequests + "/assets/", asset);
116 } 118 }
117 catch (Exception e) 119 catch (Exception e)
118 { 120 {
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