aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Server/Handlers/Asset/AssetServerPostHandler.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Server/Handlers/Asset/AssetServerPostHandler.cs28
1 files changed, 19 insertions, 9 deletions
diff --git a/OpenSim/Server/Handlers/Asset/AssetServerPostHandler.cs b/OpenSim/Server/Handlers/Asset/AssetServerPostHandler.cs
index a006fa8..1c706a7 100644
--- a/OpenSim/Server/Handlers/Asset/AssetServerPostHandler.cs
+++ b/OpenSim/Server/Handlers/Asset/AssetServerPostHandler.cs
@@ -38,6 +38,7 @@ using System.Xml.Serialization;
38using OpenSim.Server.Base; 38using OpenSim.Server.Base;
39using OpenSim.Services.Interfaces; 39using OpenSim.Services.Interfaces;
40using OpenSim.Framework; 40using OpenSim.Framework;
41using OpenSim.Framework.ServiceAuth;
41using OpenSim.Framework.Servers.HttpServer; 42using OpenSim.Framework.Servers.HttpServer;
42 43
43namespace OpenSim.Server.Handlers.Asset 44namespace OpenSim.Server.Handlers.Asset
@@ -54,35 +55,44 @@ namespace OpenSim.Server.Handlers.Asset
54 m_AssetService = service; 55 m_AssetService = service;
55 } 56 }
56 57
57 public override byte[] Handle(string path, Stream request, 58 public AssetServerPostHandler(IAssetService service, IServiceAuth auth) :
59 base("POST", "/assets", auth)
60 {
61 m_AssetService = service;
62 }
63
64 protected override byte[] ProcessRequest(string path, Stream request,
58 IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) 65 IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
59 { 66 {
60 AssetBase asset; 67 AssetBase asset;
61 XmlSerializer xs = new XmlSerializer(typeof (AssetBase)); 68 XmlSerializer xs = new XmlSerializer(typeof(AssetBase));
62 69
63 try 70 try
64 { 71 {
65 asset = (AssetBase)xs.Deserialize(request); 72 asset = (AssetBase)xs.Deserialize(request);
66 } 73 }
67 catch (XmlException) 74 catch (Exception)
68 { 75 {
69 httpResponse.StatusCode = (int)HttpStatusCode.BadRequest; 76 httpResponse.StatusCode = (int)HttpStatusCode.BadRequest;
70 return null; 77 return null;
71 } 78 }
72 79
73 string[] p = SplitParams(path); 80 string[] p = SplitParams(path);
74 if (p.Length > 1) 81 if (p.Length > 0)
75 { 82 {
76 bool result = m_AssetService.UpdateContent(p[1], asset.Data); 83 string id = p[0];
84 bool result = m_AssetService.UpdateContent(id, asset.Data);
77 85
78 xs = new XmlSerializer(typeof(bool)); 86 xs = new XmlSerializer(typeof(bool));
79 return ServerUtils.SerializeResult(xs, result); 87 return ServerUtils.SerializeResult(xs, result);
80 } 88 }
89 else
90 {
91 string id = m_AssetService.Store(asset);
81 92
82 string id = m_AssetService.Store(asset); 93 xs = new XmlSerializer(typeof(string));
83 94 return ServerUtils.SerializeResult(xs, id);
84 xs = new XmlSerializer(typeof(string)); 95 }
85 return ServerUtils.SerializeResult(xs, id);
86 } 96 }
87 } 97 }
88} 98}