aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Servers
diff options
context:
space:
mode:
authorJohn Hurliman2009-09-30 15:28:23 -0700
committerJohn Hurliman2009-09-30 15:28:23 -0700
commitacfe2d9f4e5a55d38b16cac7d0d0a25b64b6b009 (patch)
tree305349e1bd0a5849fd7f96483e24d5e07b24b8f4 /OpenSim/Framework/Servers
parent* Adding Scale to EntityBase * Fixing the incorrect initialization of EntityB... (diff)
parentFormatting cleanup. (diff)
downloadopensim-SC_OLD-acfe2d9f4e5a55d38b16cac7d0d0a25b64b6b009.zip
opensim-SC_OLD-acfe2d9f4e5a55d38b16cac7d0d0a25b64b6b009.tar.gz
opensim-SC_OLD-acfe2d9f4e5a55d38b16cac7d0d0a25b64b6b009.tar.bz2
opensim-SC_OLD-acfe2d9f4e5a55d38b16cac7d0d0a25b64b6b009.tar.xz
Merge branch 'master' of ssh://opensimulator.org/var/git/opensim
Diffstat (limited to 'OpenSim/Framework/Servers')
-rw-r--r--OpenSim/Framework/Servers/BaseGetAssetStreamHandler.cs205
-rw-r--r--OpenSim/Framework/Servers/BaseOpenSimServer.cs12
-rw-r--r--OpenSim/Framework/Servers/CheckSumServer.cs26
-rw-r--r--OpenSim/Framework/Servers/GetAssetStreamHandler.cs63
-rw-r--r--OpenSim/Framework/Servers/HttpServer/AsynchronousRestObjectRequester.cs2
-rw-r--r--OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs112
-rw-r--r--OpenSim/Framework/Servers/HttpServer/Interfaces/IHttpServer.cs2
-rw-r--r--OpenSim/Framework/Servers/HttpServer/PollServiceEventArgs.cs11
-rw-r--r--OpenSim/Framework/Servers/HttpServer/PollServiceHttpRequest.cs3
-rw-r--r--OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs2
-rw-r--r--OpenSim/Framework/Servers/HttpServer/PollServiceWorkerThread.cs6
-rw-r--r--OpenSim/Framework/Servers/HttpServer/SynchronousRestFormsRequester.cs95
-rw-r--r--OpenSim/Framework/Servers/PostAssetStreamHandler.cs72
-rw-r--r--OpenSim/Framework/Servers/Tests/GetAssetStreamHandlerTests.cs135
-rw-r--r--OpenSim/Framework/Servers/VersionInfo.cs6
15 files changed, 183 insertions, 569 deletions
diff --git a/OpenSim/Framework/Servers/BaseGetAssetStreamHandler.cs b/OpenSim/Framework/Servers/BaseGetAssetStreamHandler.cs
deleted file mode 100644
index 8372ae7..0000000
--- a/OpenSim/Framework/Servers/BaseGetAssetStreamHandler.cs
+++ /dev/null
@@ -1,205 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic;
30using System.IO;
31using System.Net;
32using System.Reflection;
33using System.Text;
34using System.Text.RegularExpressions;
35using System.Xml;
36using System.Xml.Serialization;
37using log4net;
38using OpenMetaverse;
39using OpenSim.Framework.Servers.HttpServer;
40using OpenSim.Framework.Statistics;
41
42namespace OpenSim.Framework.Servers
43{
44 public abstract class BaseGetAssetStreamHandler : BaseStreamHandler
45 {
46 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
47
48 protected BaseGetAssetStreamHandler(string httpMethod, string path) : base(httpMethod, path)
49 {
50 }
51
52 protected abstract AssetBase GetAsset(UUID assetID);
53
54 public override byte[] Handle(string path, Stream request,
55 OSHttpRequest httpRequest, OSHttpResponse httpResponse)
56 {
57 byte[] result = new byte[] { };
58
59 string[] p = SplitParams(path);
60
61 if (p.Length > 0)
62 {
63 UUID assetID;
64
65 if (!UUID.TryParse(p[0], out assetID))
66 {
67 m_log.DebugFormat(
68 "[REST]: GET:/asset ignoring request with malformed UUID {0}", p[0]);
69 return result;
70 }
71
72 if (StatsManager.AssetStats != null)
73 {
74 StatsManager.AssetStats.AddRequest();
75 }
76
77 AssetBase asset = GetAsset(assetID);
78
79 if (asset != null)
80 {
81 if (p.Length > 1 && p[1] == "data")
82 {
83 httpResponse.StatusCode = (int)HttpStatusCode.OK;
84 httpResponse.ContentType = SLAssetTypeToContentType(asset.Type);
85 result = asset.Data;
86 }
87 else
88 {
89 result = GetXml(asset);
90 }
91 }
92 else
93 {
94 m_log.DebugFormat("[REST]: GET:/asset failed to find {0}", assetID);
95
96 httpResponse.StatusCode = (int)HttpStatusCode.NotFound;
97
98 if (StatsManager.AssetStats != null)
99 {
100 StatsManager.AssetStats.AddNotFoundRequest();
101 }
102 }
103 }
104
105 return result;
106 }
107
108 public static byte[] GetXml(AssetBase asset)
109 {
110 byte[] result;
111 XmlSerializer xs = new XmlSerializer(typeof(AssetBase));
112 MemoryStream ms = new MemoryStream();
113 XmlTextWriter xw = new XmlTextWriter(ms, Encoding.UTF8);
114 xw.Formatting = Formatting.Indented;
115 xs.Serialize(xw, asset);
116 xw.Flush();
117
118 ms.Seek(0, SeekOrigin.Begin);
119 //StreamReader sr = new StreamReader(ms);
120
121 result = ms.GetBuffer();
122
123 Array.Resize<byte>(ref result, (int)ms.Length);
124 return result;
125 }
126
127 public string ProcessAssetDataString(string data)
128 {
129 Regex regex = new Regex("(creator_id|owner_id)\\s+(\\S+)");
130
131 // IUserService userService = null;
132
133 data = regex.Replace(data, delegate(Match m)
134 {
135 string result = String.Empty;
136
137// string key = m.Groups[1].Captures[0].Value;
138//
139// string value = m.Groups[2].Captures[0].Value;
140//
141// Guid userUri;
142//
143// switch (key)
144// {
145// case "creator_id":
146// userUri = new Guid(value);
147// // result = "creator_url " + userService(userService, userUri);
148// break;
149//
150// case "owner_id":
151// userUri = new Guid(value);
152// // result = "owner_url " + ResolveUserUri(userService, userUri);
153// break;
154// }
155
156 return result;
157 });
158
159 return data;
160 }
161
162 private string SLAssetTypeToContentType(int assetType)
163 {
164 switch (assetType)
165 {
166 case 0:
167 return "image/jp2";
168 case 1:
169 return "application/ogg";
170 case 2:
171 return "application/x-metaverse-callingcard";
172 case 3:
173 return "application/x-metaverse-landmark";
174 case 5:
175 return "application/x-metaverse-clothing";
176 case 6:
177 return "application/x-metaverse-primitive";
178 case 7:
179 return "application/x-metaverse-notecard";
180 case 8:
181 return "application/x-metaverse-folder";
182 case 10:
183 return "application/x-metaverse-lsl";
184 case 11:
185 return "application/x-metaverse-lso";
186 case 12:
187 return "image/tga";
188 case 13:
189 return "application/x-metaverse-bodypart";
190 case 17:
191 return "audio/x-wav";
192 case 19:
193 return "image/jpeg";
194 case 20:
195 return "application/x-metaverse-animation";
196 case 21:
197 return "application/x-metaverse-gesture";
198 case 22:
199 return "application/x-metaverse-simstate";
200 default:
201 return "application/octet-stream";
202 }
203 }
204 }
205}
diff --git a/OpenSim/Framework/Servers/BaseOpenSimServer.cs b/OpenSim/Framework/Servers/BaseOpenSimServer.cs
index 7a244ff..632b551 100644
--- a/OpenSim/Framework/Servers/BaseOpenSimServer.cs
+++ b/OpenSim/Framework/Servers/BaseOpenSimServer.cs
@@ -158,7 +158,7 @@ namespace OpenSim.Framework.Servers
158 m_consoleAppender.Threshold = Level.All; 158 m_consoleAppender.Threshold = Level.All;
159 159
160 Notice(String.Format("Console log level is {0}", m_consoleAppender.Threshold)); 160 Notice(String.Format("Console log level is {0}", m_consoleAppender.Threshold));
161 } 161 }
162 162
163 m_console.Commands.AddCommand("base", false, "quit", 163 m_console.Commands.AddCommand("base", false, "quit",
164 "quit", 164 "quit",
@@ -196,7 +196,7 @@ namespace OpenSim.Framework.Servers
196 196
197 /// <summary> 197 /// <summary>
198 /// Should be overriden and referenced by descendents if they need to perform extra shutdown processing 198 /// Should be overriden and referenced by descendents if they need to perform extra shutdown processing
199 /// </summary> 199 /// </summary>
200 public virtual void ShutdownSpecific() {} 200 public virtual void ShutdownSpecific() {}
201 201
202 /// <summary> 202 /// <summary>
@@ -286,7 +286,7 @@ namespace OpenSim.Framework.Servers
286 /// </summary> 286 /// </summary>
287 public virtual void Startup() 287 public virtual void Startup()
288 { 288 {
289 m_log.Info("[STARTUP]: Beginning startup processing"); 289 m_log.Info("[STARTUP]: Beginning startup processing");
290 290
291 EnhanceVersionInformation(); 291 EnhanceVersionInformation();
292 292
@@ -301,7 +301,7 @@ namespace OpenSim.Framework.Servers
301 301
302 /// <summary> 302 /// <summary>
303 /// Should be overriden and referenced by descendents if they need to perform extra shutdown processing 303 /// Should be overriden and referenced by descendents if they need to perform extra shutdown processing
304 /// </summary> 304 /// </summary>
305 public virtual void Shutdown() 305 public virtual void Shutdown()
306 { 306 {
307 ShutdownSpecific(); 307 ShutdownSpecific();
@@ -367,7 +367,7 @@ namespace OpenSim.Framework.Servers
367 } 367 }
368 368
369 public virtual void HandleShow(string module, string[] cmd) 369 public virtual void HandleShow(string module, string[] cmd)
370 { 370 {
371 List<string> args = new List<string>(cmd); 371 List<string> args = new List<string>(cmd);
372 372
373 args.RemoveAt(0); 373 args.RemoveAt(0);
@@ -375,7 +375,7 @@ namespace OpenSim.Framework.Servers
375 string[] showParams = args.ToArray(); 375 string[] showParams = args.ToArray();
376 376
377 switch (showParams[0]) 377 switch (showParams[0])
378 { 378 {
379 case "info": 379 case "info":
380 Notice("Version: " + m_version); 380 Notice("Version: " + m_version);
381 Notice("Startup directory: " + m_startupDirectory); 381 Notice("Startup directory: " + m_startupDirectory);
diff --git a/OpenSim/Framework/Servers/CheckSumServer.cs b/OpenSim/Framework/Servers/CheckSumServer.cs
deleted file mode 100644
index ad5281d..0000000
--- a/OpenSim/Framework/Servers/CheckSumServer.cs
+++ /dev/null
@@ -1,26 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
diff --git a/OpenSim/Framework/Servers/GetAssetStreamHandler.cs b/OpenSim/Framework/Servers/GetAssetStreamHandler.cs
deleted file mode 100644
index c6958de..0000000
--- a/OpenSim/Framework/Servers/GetAssetStreamHandler.cs
+++ /dev/null
@@ -1,63 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.IO;
30using System.Reflection;
31using System.Text;
32using System.Text.RegularExpressions;
33using System.Xml;
34using System.Xml.Serialization;
35using log4net;
36using OpenMetaverse;
37using OpenSim.Data;
38using OpenSim.Framework;
39using OpenSim.Framework.Servers;
40using OpenSim.Framework.Servers.HttpServer;
41using OpenSim.Framework.Statistics;
42using System.Net;
43
44namespace OpenSim.Framework.Servers
45{
46 public class GetAssetStreamHandler : BaseGetAssetStreamHandler
47 {
48 // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
49
50 private readonly IAssetDataPlugin m_assetProvider;
51
52 public GetAssetStreamHandler(IAssetDataPlugin assetProvider)
53 : base("GET", "/assets")
54 {
55 m_assetProvider = assetProvider;
56 }
57
58 protected override AssetBase GetAsset(UUID assetID)
59 {
60 return m_assetProvider.GetAsset(assetID);
61 }
62 }
63}
diff --git a/OpenSim/Framework/Servers/HttpServer/AsynchronousRestObjectRequester.cs b/OpenSim/Framework/Servers/HttpServer/AsynchronousRestObjectRequester.cs
index fe69ad3..5afa110 100644
--- a/OpenSim/Framework/Servers/HttpServer/AsynchronousRestObjectRequester.cs
+++ b/OpenSim/Framework/Servers/HttpServer/AsynchronousRestObjectRequester.cs
@@ -168,7 +168,7 @@ namespace OpenSim.Framework.Servers.HttpServer
168 "[ASYNC REQUEST]: Request {0} {1} callback failed with exception {2}", verb, requestUrl, e); 168 "[ASYNC REQUEST]: Request {0} {1} callback failed with exception {2}", verb, requestUrl, e);
169 } 169 }
170 170
171 }, null); 171 }, null);
172 } 172 }
173 } 173 }
174} 174}
diff --git a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs
index 771ae05..6c63c6c 100644
--- a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs
+++ b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs
@@ -110,7 +110,7 @@ namespace OpenSim.Framework.Servers.HttpServer
110 110
111 public BaseHttpServer(uint port, bool ssl) : this (port) 111 public BaseHttpServer(uint port, bool ssl) : this (port)
112 { 112 {
113 m_ssl = ssl; 113 m_ssl = ssl;
114 } 114 }
115 115
116 public BaseHttpServer(uint port, bool ssl, uint sslport, string CN) : this (port, ssl) 116 public BaseHttpServer(uint port, bool ssl, uint sslport, string CN) : this (port, ssl)
@@ -156,7 +156,7 @@ namespace OpenSim.Framework.Servers.HttpServer
156 lock (m_rpcHandlers) 156 lock (m_rpcHandlers)
157 { 157 {
158 m_rpcHandlers[method] = handler; 158 m_rpcHandlers[method] = handler;
159 m_rpcHandlersKeepAlive[method] = keepAlive; // default 159 m_rpcHandlersKeepAlive[method] = keepAlive; // default
160 } 160 }
161 161
162 return true; 162 return true;
@@ -256,13 +256,51 @@ namespace OpenSim.Framework.Servers.HttpServer
256 IHttpClientContext context = (IHttpClientContext)source; 256 IHttpClientContext context = (IHttpClientContext)source;
257 IHttpRequest request = args.Request; 257 IHttpRequest request = args.Request;
258 258
259
260 PollServiceEventArgs psEvArgs; 259 PollServiceEventArgs psEvArgs;
260
261 if (TryGetPollServiceHTTPHandler(request.UriPath.ToString(), out psEvArgs)) 261 if (TryGetPollServiceHTTPHandler(request.UriPath.ToString(), out psEvArgs))
262 { 262 {
263 263 PollServiceHttpRequest psreq = new PollServiceHttpRequest(psEvArgs, context, request);
264 m_PollServiceManager.Enqueue(new PollServiceHttpRequest(psEvArgs, context, request)); 264
265 //DoHTTPGruntWork(psEvArgs.NoEvents(),new OSHttpResponse(new HttpResponse(context, request))); 265 if (psEvArgs.Request != null)
266 {
267 OSHttpRequest req = new OSHttpRequest(context, request);
268
269 Stream requestStream = req.InputStream;
270
271 Encoding encoding = Encoding.UTF8;
272 StreamReader reader = new StreamReader(requestStream, encoding);
273
274 string requestBody = reader.ReadToEnd();
275
276 Hashtable keysvals = new Hashtable();
277 Hashtable headervals = new Hashtable();
278
279 string[] querystringkeys = req.QueryString.AllKeys;
280 string[] rHeaders = req.Headers.AllKeys;
281
282 keysvals.Add("body", requestBody);
283 keysvals.Add("uri", req.RawUrl);
284 keysvals.Add("content-type", req.ContentType);
285 keysvals.Add("http-method", req.HttpMethod);
286
287 foreach (string queryname in querystringkeys)
288 {
289 keysvals.Add(queryname, req.QueryString[queryname]);
290 }
291
292 foreach (string headername in rHeaders)
293 {
294 headervals[headername] = req.Headers[headername];
295 }
296
297 keysvals.Add("headers",headervals);
298 keysvals.Add("querystringkeys", querystringkeys);
299
300 psEvArgs.Request(psreq.RequestID, keysvals);
301 }
302
303 m_PollServiceManager.Enqueue(psreq);
266 } 304 }
267 else 305 else
268 { 306 {
@@ -275,49 +313,17 @@ namespace OpenSim.Framework.Servers.HttpServer
275 { 313 {
276 OSHttpRequest req = new OSHttpRequest(context, request); 314 OSHttpRequest req = new OSHttpRequest(context, request);
277 OSHttpResponse resp = new OSHttpResponse(new HttpResponse(context, request),context); 315 OSHttpResponse resp = new OSHttpResponse(new HttpResponse(context, request),context);
278 //resp.KeepAlive = req.KeepAlive;
279 //m_log.Info("[Debug BASE HTTP SERVER]: Got Request");
280 //HttpServerContextObj objstate= new HttpServerContextObj(req,resp);
281 //ThreadPool.QueueUserWorkItem(new WaitCallback(ConvertIHttpClientContextToOSHttp), (object)objstate);
282 HandleRequest(req, resp); 316 HandleRequest(req, resp);
283 } 317 }
284 318
285 public void ConvertIHttpClientContextToOSHttp(object stateinfo) 319 public void ConvertIHttpClientContextToOSHttp(object stateinfo)
286 { 320 {
287 HttpServerContextObj objstate = (HttpServerContextObj)stateinfo; 321 HttpServerContextObj objstate = (HttpServerContextObj)stateinfo;
288 //OSHttpRequest request = new OSHttpRequest(objstate.context,objstate.req);
289 //OSHttpResponse resp = new OSHttpResponse(new HttpServer.HttpResponse(objstate.context, objstate.req));
290 322
291 OSHttpRequest request = objstate.oreq; 323 OSHttpRequest request = objstate.oreq;
292 OSHttpResponse resp = objstate.oresp; 324 OSHttpResponse resp = objstate.oresp;
293 //OSHttpResponse resp = new OSHttpResponse(new HttpServer.HttpResponse(objstate.context, objstate.req));
294 325
295 /* 326 HandleRequest(request,resp);
296 request.AcceptTypes = objstate.req.AcceptTypes;
297 request.ContentLength = (long)objstate.req.ContentLength;
298 request.Headers = objstate.req.Headers;
299 request.HttpMethod = objstate.req.Method;
300 request.InputStream = objstate.req.Body;
301 foreach (string str in request.Headers)
302 {
303 if (str.ToLower().Contains("content-type: "))
304 {
305 request.ContentType = str.Substring(13, str.Length - 13);
306 break;
307 }
308 }
309 //request.KeepAlive = objstate.req.
310 foreach (HttpServer.HttpInput httpinput in objstate.req.QueryString)
311 {
312 request.QueryString.Add(httpinput.Name, httpinput[httpinput.Name]);
313 }
314
315 //request.Query = objstate.req.//objstate.req.QueryString;
316 //foreach (
317 //request.QueryString = objstate.req.QueryString;
318
319 */
320 HandleRequest(request,resp);
321 } 327 }
322 328
323 public virtual void HandleRequest(OSHttpRequest request, OSHttpResponse response) 329 public virtual void HandleRequest(OSHttpRequest request, OSHttpResponse response)
@@ -332,6 +338,7 @@ namespace OpenSim.Framework.Servers.HttpServer
332 // probability event; if a request is matched it is normally expected to be 338 // probability event; if a request is matched it is normally expected to be
333 // handled 339 // handled
334 //m_log.Debug("[BASE HTTP SERVER]: Handling Request" + request.RawUrl); 340 //m_log.Debug("[BASE HTTP SERVER]: Handling Request" + request.RawUrl);
341
335 IHttpAgentHandler agentHandler; 342 IHttpAgentHandler agentHandler;
336 343
337 if (TryGetAgentHandler(request, response, out agentHandler)) 344 if (TryGetAgentHandler(request, response, out agentHandler))
@@ -342,10 +349,11 @@ namespace OpenSim.Framework.Servers.HttpServer
342 } 349 }
343 } 350 }
344 351
345 IRequestHandler requestHandler;
346 //response.KeepAlive = true; 352 //response.KeepAlive = true;
347 response.SendChunked = false; 353 response.SendChunked = false;
348 354
355 IRequestHandler requestHandler;
356
349 string path = request.RawUrl; 357 string path = request.RawUrl;
350 string handlerKey = GetHandlerKey(request.HttpMethod, path); 358 string handlerKey = GetHandlerKey(request.HttpMethod, path);
351 359
@@ -359,6 +367,7 @@ namespace OpenSim.Framework.Servers.HttpServer
359 367
360 response.ContentType = requestHandler.ContentType; // Lets do this defaulting before in case handler has varying content type. 368 response.ContentType = requestHandler.ContentType; // Lets do this defaulting before in case handler has varying content type.
361 369
370
362 if (requestHandler is IStreamedRequestHandler) 371 if (requestHandler is IStreamedRequestHandler)
363 { 372 {
364 IStreamedRequestHandler streamedRequestHandler = requestHandler as IStreamedRequestHandler; 373 IStreamedRequestHandler streamedRequestHandler = requestHandler as IStreamedRequestHandler;
@@ -404,6 +413,7 @@ namespace OpenSim.Framework.Servers.HttpServer
404 // } 413 // }
405 414
406 keysvals.Add("requestbody", requestBody); 415 keysvals.Add("requestbody", requestBody);
416 keysvals.Add("headers",headervals);
407 if (keysvals.Contains("method")) 417 if (keysvals.Contains("method"))
408 { 418 {
409 //m_log.Warn("[HTTP]: Contains Method"); 419 //m_log.Warn("[HTTP]: Contains Method");
@@ -702,7 +712,7 @@ namespace OpenSim.Framework.Servers.HttpServer
702 lock (m_rpcHandlers) 712 lock (m_rpcHandlers)
703 { 713 {
704 methodWasFound = m_rpcHandlers.TryGetValue(methodName, out method); 714 methodWasFound = m_rpcHandlers.TryGetValue(methodName, out method);
705 } 715 }
706 716
707 if (methodWasFound) 717 if (methodWasFound)
708 { 718 {
@@ -726,8 +736,11 @@ namespace OpenSim.Framework.Servers.HttpServer
726 else 736 else
727 { 737 {
728 xmlRpcResponse = new XmlRpcResponse(); 738 xmlRpcResponse = new XmlRpcResponse();
739
729 // Code set in accordance with http://xmlrpc-epi.sourceforge.net/specs/rfc.fault_codes.php 740 // Code set in accordance with http://xmlrpc-epi.sourceforge.net/specs/rfc.fault_codes.php
730 xmlRpcResponse.SetFault(-32601, String.Format("Requested method [{0}] not found", methodName)); 741 xmlRpcResponse.SetFault(
742 XmlRpcErrorCodes.SERVER_ERROR_METHOD,
743 String.Format("Requested method [{0}] not found", methodName));
731 } 744 }
732 745
733 responseString = XmlRpcResponseSerializer.Singleton.Serialize(xmlRpcResponse); 746 responseString = XmlRpcResponseSerializer.Singleton.Serialize(xmlRpcResponse);
@@ -747,6 +760,7 @@ namespace OpenSim.Framework.Servers.HttpServer
747 response.SendChunked = false; 760 response.SendChunked = false;
748 response.ContentLength64 = buf.Length; 761 response.ContentLength64 = buf.Length;
749 response.ContentEncoding = Encoding.UTF8; 762 response.ContentEncoding = Encoding.UTF8;
763
750 try 764 try
751 { 765 {
752 response.OutputStream.Write(buf, 0, buf.Length); 766 response.OutputStream.Write(buf, 0, buf.Length);
@@ -917,7 +931,7 @@ namespace OpenSim.Framework.Servers.HttpServer
917 } 931 }
918 catch (IOException e) 932 catch (IOException e)
919 { 933 {
920 m_log.DebugFormat("[BASE HTTP SERVER] LLSD IOException {0}.", e); 934 m_log.DebugFormat("[BASE HTTP SERVER] LLSD IOException {0}.", e);
921 } 935 }
922 catch (SocketException e) 936 catch (SocketException e)
923 { 937 {
@@ -1354,7 +1368,7 @@ namespace OpenSim.Framework.Servers.HttpServer
1354 bestMatch = pattern; 1368 bestMatch = pattern;
1355 } 1369 }
1356 } 1370 }
1357 } 1371 }
1358 1372
1359 if (String.IsNullOrEmpty(bestMatch)) 1373 if (String.IsNullOrEmpty(bestMatch))
1360 { 1374 {
@@ -1466,7 +1480,7 @@ namespace OpenSim.Framework.Servers.HttpServer
1466 { 1480 {
1467 m_log.Warn("[BASE HTTP SERVER] XmlRpcRequest issue: " + e.Message); 1481 m_log.Warn("[BASE HTTP SERVER] XmlRpcRequest issue: " + e.Message);
1468 } 1482 }
1469 } 1483 }
1470 } 1484 }
1471 1485
1472 public void SendHTML404(OSHttpResponse response, string host) 1486 public void SendHTML404(OSHttpResponse response, string host)
@@ -1575,7 +1589,7 @@ namespace OpenSim.Framework.Servers.HttpServer
1575 // if you want more detailed trace information from the HttpServer 1589 // if you want more detailed trace information from the HttpServer
1576 //m_httpListener2.UseTraceLogs = true; 1590 //m_httpListener2.UseTraceLogs = true;
1577 1591
1578 //m_httpListener2.DisconnectHandler = httpServerDisconnectMonitor; 1592 //m_httpListener2.DisconnectHandler = httpServerDisconnectMonitor;
1579 } 1593 }
1580 else 1594 else
1581 { 1595 {
@@ -1610,7 +1624,7 @@ namespace OpenSim.Framework.Servers.HttpServer
1610 } 1624 }
1611 1625
1612 public void httpServerDisconnectMonitor(IHttpClientContext source, SocketError err) 1626 public void httpServerDisconnectMonitor(IHttpClientContext source, SocketError err)
1613 { 1627 {
1614 switch (err) 1628 switch (err)
1615 { 1629 {
1616 case SocketError.NotSocket: 1630 case SocketError.NotSocket:
@@ -1621,7 +1635,7 @@ namespace OpenSim.Framework.Servers.HttpServer
1621 } 1635 }
1622 1636
1623 public void httpServerException(object source, Exception exception) 1637 public void httpServerException(object source, Exception exception)
1624 { 1638 {
1625 m_log.ErrorFormat("[HTTPSERVER]: {0} had an exception {1}", source.ToString(), exception.ToString()); 1639 m_log.ErrorFormat("[HTTPSERVER]: {0} had an exception {1}", source.ToString(), exception.ToString());
1626 /* 1640 /*
1627 if (HTTPDRunning)// && NotSocketErrors > 5) 1641 if (HTTPDRunning)// && NotSocketErrors > 5)
@@ -1648,7 +1662,7 @@ namespace OpenSim.Framework.Servers.HttpServer
1648 } 1662 }
1649 catch (NullReferenceException) 1663 catch (NullReferenceException)
1650 { 1664 {
1651 m_log.Warn("[BASEHTTPSERVER]: Null Reference when stopping HttpServer."); 1665 m_log.Warn("[BASEHTTPSERVER]: Null Reference when stopping HttpServer.");
1652 } 1666 }
1653 1667
1654 } 1668 }
diff --git a/OpenSim/Framework/Servers/HttpServer/Interfaces/IHttpServer.cs b/OpenSim/Framework/Servers/HttpServer/Interfaces/IHttpServer.cs
index 1bdf4fa..d13408d 100644
--- a/OpenSim/Framework/Servers/HttpServer/Interfaces/IHttpServer.cs
+++ b/OpenSim/Framework/Servers/HttpServer/Interfaces/IHttpServer.cs
@@ -128,6 +128,6 @@ namespace OpenSim.Framework.Servers.HttpServer
128 128
129 string GetHTTP404(string host); 129 string GetHTTP404(string host);
130 130
131 string GetHTTP500(); 131 string GetHTTP500();
132 } 132 }
133} 133}
diff --git a/OpenSim/Framework/Servers/HttpServer/PollServiceEventArgs.cs b/OpenSim/Framework/Servers/HttpServer/PollServiceEventArgs.cs
index fed490e..9d512c6 100644
--- a/OpenSim/Framework/Servers/HttpServer/PollServiceEventArgs.cs
+++ b/OpenSim/Framework/Servers/HttpServer/PollServiceEventArgs.cs
@@ -30,20 +30,23 @@ using System.Collections;
30using OpenMetaverse; 30using OpenMetaverse;
31namespace OpenSim.Framework.Servers.HttpServer 31namespace OpenSim.Framework.Servers.HttpServer
32{ 32{
33 public delegate bool HasEventsMethod(UUID pId); 33 public delegate void RequestMethod(UUID requestID, Hashtable request);
34 public delegate bool HasEventsMethod(UUID requestID, UUID pId);
34 35
35 public delegate Hashtable GetEventsMethod(UUID pId, string request); 36 public delegate Hashtable GetEventsMethod(UUID requestID, UUID pId, string request);
36 37
37 public delegate Hashtable NoEventsMethod(); 38 public delegate Hashtable NoEventsMethod(UUID requestID, UUID pId);
38 39
39 public class PollServiceEventArgs : EventArgs 40 public class PollServiceEventArgs : EventArgs
40 { 41 {
41 public HasEventsMethod HasEvents; 42 public HasEventsMethod HasEvents;
42 public GetEventsMethod GetEvents; 43 public GetEventsMethod GetEvents;
43 public NoEventsMethod NoEvents; 44 public NoEventsMethod NoEvents;
45 public RequestMethod Request;
44 public UUID Id; 46 public UUID Id;
45 public PollServiceEventArgs(HasEventsMethod pHasEvents, GetEventsMethod pGetEvents, NoEventsMethod pNoEvents,UUID pId) 47 public PollServiceEventArgs(RequestMethod pRequest, HasEventsMethod pHasEvents, GetEventsMethod pGetEvents, NoEventsMethod pNoEvents,UUID pId)
46 { 48 {
49 Request = pRequest;
47 HasEvents = pHasEvents; 50 HasEvents = pHasEvents;
48 GetEvents = pGetEvents; 51 GetEvents = pGetEvents;
49 NoEvents = pNoEvents; 52 NoEvents = pNoEvents;
diff --git a/OpenSim/Framework/Servers/HttpServer/PollServiceHttpRequest.cs b/OpenSim/Framework/Servers/HttpServer/PollServiceHttpRequest.cs
index ff7c1e8..553a7eb 100644
--- a/OpenSim/Framework/Servers/HttpServer/PollServiceHttpRequest.cs
+++ b/OpenSim/Framework/Servers/HttpServer/PollServiceHttpRequest.cs
@@ -27,6 +27,7 @@
27 27
28using System; 28using System;
29using HttpServer; 29using HttpServer;
30using OpenMetaverse;
30 31
31namespace OpenSim.Framework.Servers.HttpServer 32namespace OpenSim.Framework.Servers.HttpServer
32{ 33{
@@ -37,12 +38,14 @@ namespace OpenSim.Framework.Servers.HttpServer
37 public readonly IHttpClientContext HttpContext; 38 public readonly IHttpClientContext HttpContext;
38 public readonly IHttpRequest Request; 39 public readonly IHttpRequest Request;
39 public readonly int RequestTime; 40 public readonly int RequestTime;
41 public readonly UUID RequestID;
40 public PollServiceHttpRequest(PollServiceEventArgs pPollServiceArgs, IHttpClientContext pHttpContext, IHttpRequest pRequest) 42 public PollServiceHttpRequest(PollServiceEventArgs pPollServiceArgs, IHttpClientContext pHttpContext, IHttpRequest pRequest)
41 { 43 {
42 PollServiceArgs = pPollServiceArgs; 44 PollServiceArgs = pPollServiceArgs;
43 HttpContext = pHttpContext; 45 HttpContext = pHttpContext;
44 Request = pRequest; 46 Request = pRequest;
45 RequestTime = System.Environment.TickCount; 47 RequestTime = System.Environment.TickCount;
48 RequestID = UUID.Random();
46 } 49 }
47 } 50 }
48} 51}
diff --git a/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs b/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs
index 4020190..1c54581 100644
--- a/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs
+++ b/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs
@@ -130,7 +130,7 @@ namespace OpenSim.Framework.Servers.HttpServer
130 foreach (object o in m_requests) 130 foreach (object o in m_requests)
131 { 131 {
132 PollServiceHttpRequest req = (PollServiceHttpRequest) o; 132 PollServiceHttpRequest req = (PollServiceHttpRequest) o;
133 m_server.DoHTTPGruntWork(req.PollServiceArgs.NoEvents(), new OSHttpResponse(new HttpResponse(req.HttpContext, req.Request), req.HttpContext)); 133 m_server.DoHTTPGruntWork(req.PollServiceArgs.NoEvents(req.RequestID, req.PollServiceArgs.Id), new OSHttpResponse(new HttpResponse(req.HttpContext, req.Request), req.HttpContext));
134 } 134 }
135 135
136 m_requests.Clear(); 136 m_requests.Clear();
diff --git a/OpenSim/Framework/Servers/HttpServer/PollServiceWorkerThread.cs b/OpenSim/Framework/Servers/HttpServer/PollServiceWorkerThread.cs
index 41fb376..ce32443 100644
--- a/OpenSim/Framework/Servers/HttpServer/PollServiceWorkerThread.cs
+++ b/OpenSim/Framework/Servers/HttpServer/PollServiceWorkerThread.cs
@@ -100,11 +100,11 @@ namespace OpenSim.Framework.Servers.HttpServer
100 PollServiceHttpRequest req = m_request.Dequeue(); 100 PollServiceHttpRequest req = m_request.Dequeue();
101 try 101 try
102 { 102 {
103 if (req.PollServiceArgs.HasEvents(req.PollServiceArgs.Id)) 103 if (req.PollServiceArgs.HasEvents(req.RequestID, req.PollServiceArgs.Id))
104 { 104 {
105 StreamReader str = new StreamReader(req.Request.Body); 105 StreamReader str = new StreamReader(req.Request.Body);
106 106
107 Hashtable responsedata = req.PollServiceArgs.GetEvents(req.PollServiceArgs.Id, str.ReadToEnd()); 107 Hashtable responsedata = req.PollServiceArgs.GetEvents(req.RequestID, req.PollServiceArgs.Id, str.ReadToEnd());
108 m_server.DoHTTPGruntWork(responsedata, 108 m_server.DoHTTPGruntWork(responsedata,
109 new OSHttpResponse(new HttpResponse(req.HttpContext, req.Request),req.HttpContext)); 109 new OSHttpResponse(new HttpResponse(req.HttpContext, req.Request),req.HttpContext));
110 } 110 }
@@ -112,7 +112,7 @@ namespace OpenSim.Framework.Servers.HttpServer
112 { 112 {
113 if ((Environment.TickCount - req.RequestTime) > m_timeout) 113 if ((Environment.TickCount - req.RequestTime) > m_timeout)
114 { 114 {
115 m_server.DoHTTPGruntWork(req.PollServiceArgs.NoEvents(), 115 m_server.DoHTTPGruntWork(req.PollServiceArgs.NoEvents(req.RequestID, req.PollServiceArgs.Id),
116 new OSHttpResponse(new HttpResponse(req.HttpContext, req.Request),req.HttpContext)); 116 new OSHttpResponse(new HttpResponse(req.HttpContext, req.Request),req.HttpContext));
117 } 117 }
118 else 118 else
diff --git a/OpenSim/Framework/Servers/HttpServer/SynchronousRestFormsRequester.cs b/OpenSim/Framework/Servers/HttpServer/SynchronousRestFormsRequester.cs
new file mode 100644
index 0000000..a0d4008
--- /dev/null
+++ b/OpenSim/Framework/Servers/HttpServer/SynchronousRestFormsRequester.cs
@@ -0,0 +1,95 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.IO;
30using System.Net;
31using System.Text;
32using System.Xml;
33using System.Xml.Serialization;
34
35namespace OpenSim.Framework.Servers.HttpServer
36{
37 public class SynchronousRestFormsRequester
38 {
39 /// <summary>
40 /// Perform a synchronous REST request.
41 /// </summary>
42 /// <param name="verb"></param>
43 /// <param name="requestUrl"></param>
44 /// <param name="obj"> </param>
45 /// <returns></returns>
46 ///
47 /// <exception cref="System.Net.WebException">Thrown if we encounter a network issue while posting
48 /// the request. You'll want to make sure you deal with this as they're not uncommon</exception>
49 public static string MakeRequest(string verb, string requestUrl, string obj)
50 {
51 WebRequest request = WebRequest.Create(requestUrl);
52 request.Method = verb;
53
54 if ((verb == "POST") || (verb == "PUT"))
55 {
56 request.ContentType = "text/www-form-urlencoded";
57
58 MemoryStream buffer = new MemoryStream();
59 int length = 0;
60 using (StreamWriter writer = new StreamWriter(buffer))
61 {
62 writer.Write(obj);
63 writer.Flush();
64 }
65
66 length = (int)obj.Length;
67 request.ContentLength = length;
68
69 Stream requestStream = request.GetRequestStream();
70 requestStream.Write(buffer.ToArray(), 0, length);
71 }
72
73 string respstring = String.Empty;
74
75 try
76 {
77 using (WebResponse resp = request.GetResponse())
78 {
79 if (resp.ContentLength > 0)
80 {
81 using (StreamReader reader = new StreamReader(resp.GetResponseStream()))
82 {
83 respstring = reader.ReadToEnd();
84 }
85 }
86 }
87 }
88 catch (System.InvalidOperationException)
89 {
90 // This is what happens when there is invalid XML
91 }
92 return respstring;
93 }
94 }
95}
diff --git a/OpenSim/Framework/Servers/PostAssetStreamHandler.cs b/OpenSim/Framework/Servers/PostAssetStreamHandler.cs
deleted file mode 100644
index 8bf406c..0000000
--- a/OpenSim/Framework/Servers/PostAssetStreamHandler.cs
+++ /dev/null
@@ -1,72 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System.IO;
29using System.Reflection;
30using System.Xml.Serialization;
31using log4net;
32using OpenMetaverse;
33using OpenSim.Data;
34using OpenSim.Framework;
35using OpenSim.Framework.Servers.HttpServer;
36
37namespace OpenSim.Framework.Servers
38{
39 public class PostAssetStreamHandler : BaseStreamHandler
40 {
41 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
42
43 // private OpenAsset_Main m_assetManager;
44 private IAssetDataPlugin m_assetProvider;
45
46 public override byte[] Handle(string path, Stream request,
47 OSHttpRequest httpRequest, OSHttpResponse httpResponse)
48 {
49 string param = GetParam(path);
50
51 UUID assetId;
52 if (param.Length > 0)
53 UUID.TryParse(param, out assetId);
54 // byte[] txBuffer = new byte[4096];
55
56 XmlSerializer xs = new XmlSerializer(typeof (AssetBase));
57 AssetBase asset = (AssetBase) xs.Deserialize(request);
58
59 m_log.InfoFormat("[REST]: Creating asset {0}", asset.FullID);
60 m_assetProvider.StoreAsset(asset);
61
62 return new byte[] {};
63 }
64
65 public PostAssetStreamHandler(IAssetDataPlugin assetProvider)
66 : base("POST", "/assets")
67 {
68 // m_assetManager = assetManager;
69 m_assetProvider = assetProvider;
70 }
71 }
72}
diff --git a/OpenSim/Framework/Servers/Tests/GetAssetStreamHandlerTests.cs b/OpenSim/Framework/Servers/Tests/GetAssetStreamHandlerTests.cs
deleted file mode 100644
index be3f518..0000000
--- a/OpenSim/Framework/Servers/Tests/GetAssetStreamHandlerTests.cs
+++ /dev/null
@@ -1,135 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic;
30using System.Net;
31using System.Text;
32using HttpServer;
33using NUnit.Framework;
34using OpenSim.Data;
35using OpenSim.Framework.Servers.HttpServer;
36using OpenSim.Tests.Common;
37using OpenSim.Tests.Common.Mock;
38using OpenSim.Tests.Common.Setup;
39
40namespace OpenSim.Framework.Servers.Tests
41{
42 [TestFixture]
43 public class GetAssetStreamHandlerTests
44 {
45 private const string ASSETS_PATH = "/assets";
46
47 [Test]
48 public void TestConstructor()
49 {
50 TestHelper.InMethod();
51
52 // GetAssetStreamHandler handler =
53 new GetAssetStreamHandler(null);
54 }
55
56 [Test]
57 public void TestGetParams()
58 {
59 TestHelper.InMethod();
60
61 GetAssetStreamHandler handler = new GetAssetStreamHandler(null);
62 BaseRequestHandlerTestHelper.BaseTestGetParams(handler, ASSETS_PATH);
63 }
64
65 [Test]
66 public void TestSplitParams()
67 {
68 TestHelper.InMethod();
69
70 GetAssetStreamHandler handler = new GetAssetStreamHandler(null);
71 BaseRequestHandlerTestHelper.BaseTestSplitParams(handler, ASSETS_PATH);
72 }
73
74 [Test]
75 public void TestHandleNoParams()
76 {
77 TestHelper.InMethod();
78
79 GetAssetStreamHandler handler = new GetAssetStreamHandler(null);
80
81 BaseRequestHandlerTestHelper.BaseTestHandleNoParams(handler, ASSETS_PATH);
82 }
83
84 [Test]
85 public void TestHandleMalformedGuid()
86 {
87 TestHelper.InMethod();
88
89 GetAssetStreamHandler handler = new GetAssetStreamHandler(null);
90
91 BaseRequestHandlerTestHelper.BaseTestHandleMalformedGuid(handler, ASSETS_PATH);
92 }
93
94 [Test]
95 public void TestHandleFetchMissingAsset()
96 {
97 GetAssetStreamHandler handler;
98 OSHttpResponse response;
99 CreateTestEnvironment(out handler, out response);
100
101 GetAssetStreamHandlerTestHelpers.BaseFetchMissingAsset(handler, response);
102 }
103
104 [Test]
105 public void TestHandleFetchExistingAssetData()
106 {
107 GetAssetStreamHandler handler;
108 OSHttpResponse response;
109 AssetBase asset = CreateTestEnvironment(out handler, out response);
110
111 GetAssetStreamHandlerTestHelpers.BaseFetchExistingAssetDataTest(asset, handler, response);
112 }
113
114 [Test]
115 public void TestHandleFetchExistingAssetXml()
116 {
117 GetAssetStreamHandler handler;
118 OSHttpResponse response;
119 AssetBase asset = CreateTestEnvironment(out handler, out response);
120
121 GetAssetStreamHandlerTestHelpers.BaseFetchExistingAssetXmlTest(asset, handler, response);
122 }
123
124 private static AssetBase CreateTestEnvironment(out GetAssetStreamHandler handler, out OSHttpResponse response)
125 {
126 AssetBase asset = GetAssetStreamHandlerTestHelpers.CreateCommonTestResources(out response);
127
128 IAssetDataPlugin assetDataPlugin = new TestAssetDataPlugin();
129 handler = new GetAssetStreamHandler(assetDataPlugin);
130
131 assetDataPlugin.StoreAsset(asset);
132 return asset;
133 }
134 }
135}
diff --git a/OpenSim/Framework/Servers/VersionInfo.cs b/OpenSim/Framework/Servers/VersionInfo.cs
index 743ca69..8900e46 100644
--- a/OpenSim/Framework/Servers/VersionInfo.cs
+++ b/OpenSim/Framework/Servers/VersionInfo.cs
@@ -29,7 +29,7 @@ namespace OpenSim
29{ 29{
30 public class VersionInfo 30 public class VersionInfo
31 { 31 {
32 private const string VERSION_NUMBER = "0.6.6"; 32 private const string VERSION_NUMBER = "0.6.8";
33 private const Flavour VERSION_FLAVOUR = Flavour.Dev; 33 private const Flavour VERSION_FLAVOUR = Flavour.Dev;
34 34
35 public enum Flavour 35 public enum Flavour
@@ -67,8 +67,8 @@ namespace OpenSim
67 /// 67 ///
68 /// Having this version number allows the grid service to reject connections from regions running a version 68 /// Having this version number allows the grid service to reject connections from regions running a version
69 /// of the code that is too old. 69 /// of the code that is too old.
70 /// 70 ///
71 /// </value> 71 /// </value>
72 public readonly static int MajorInterfaceVersion = 5; 72 public readonly static int MajorInterfaceVersion = 6;
73 } 73 }
74} 74}