From 4567555c49cb560dd6f109bbfec42086af3de56f Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Mon, 5 Dec 2011 20:44:20 +0000
Subject: Implement IOSHttpRequest and IOSHttpResponse http interfaces and use
instead of OSHttpRequest/OSHttpResponse.
This is required for the substitution of different HTTP servers or the newer HttpServer.dll without having to commit to a particular implementation.
This is also required to write regression tests that involve the HTTP layer.
If you need to recompile, all you need to do is replace OSHttpRequest/OSHttpResponse references with IOSHttpRequest/IOSHttpResponse.
---
OpenSim/Capabilities/Handlers/GetTexture/GetTextureHandler.cs | 6 +++---
.../Handlers/UploadBakedTexture/UploadBakedTextureHandler.cs | 2 +-
.../Handlers/WebFetchInventoryDescendents/WebFetchInvDescHandler.cs | 2 +-
OpenSim/Capabilities/LLSDStreamHandler.cs | 2 +-
4 files changed, 6 insertions(+), 6 deletions(-)
(limited to 'OpenSim/Capabilities')
diff --git a/OpenSim/Capabilities/Handlers/GetTexture/GetTextureHandler.cs b/OpenSim/Capabilities/Handlers/GetTexture/GetTextureHandler.cs
index 7ab30ce..ae95821 100644
--- a/OpenSim/Capabilities/Handlers/GetTexture/GetTextureHandler.cs
+++ b/OpenSim/Capabilities/Handlers/GetTexture/GetTextureHandler.cs
@@ -64,7 +64,7 @@ namespace OpenSim.Capabilities.Handlers
m_assetService = assService;
}
- public override byte[] Handle(string path, Stream request, OSHttpRequest httpRequest, OSHttpResponse httpResponse)
+ public override byte[] Handle(string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
{
// Try to parse the texture ID from the request URL
NameValueCollection query = HttpUtility.ParseQueryString(httpRequest.Url.Query);
@@ -127,7 +127,7 @@ namespace OpenSim.Capabilities.Handlers
///
///
/// False for "caller try another codec"; true otherwise
- private bool FetchTexture(OSHttpRequest httpRequest, OSHttpResponse httpResponse, UUID textureID, string format)
+ private bool FetchTexture(IOSHttpRequest httpRequest, IOSHttpResponse httpResponse, UUID textureID, string format)
{
// m_log.DebugFormat("[GETTEXTURE]: {0} with requested format {1}", textureID, format);
AssetBase texture;
@@ -211,7 +211,7 @@ namespace OpenSim.Capabilities.Handlers
return true;
}
- private void WriteTextureData(OSHttpRequest request, OSHttpResponse response, AssetBase texture, string format)
+ private void WriteTextureData(IOSHttpRequest request, IOSHttpResponse response, AssetBase texture, string format)
{
string range = request.Headers.GetOne("Range");
diff --git a/OpenSim/Capabilities/Handlers/UploadBakedTexture/UploadBakedTextureHandler.cs b/OpenSim/Capabilities/Handlers/UploadBakedTexture/UploadBakedTextureHandler.cs
index b89fd6a..e0ccc3c 100644
--- a/OpenSim/Capabilities/Handlers/UploadBakedTexture/UploadBakedTextureHandler.cs
+++ b/OpenSim/Capabilities/Handlers/UploadBakedTexture/UploadBakedTextureHandler.cs
@@ -73,7 +73,7 @@ namespace OpenSim.Capabilities.Handlers
///
/// The upload response if the request is successful, null otherwise.
public string UploadBakedTexture(
- string request, string path, string param, OSHttpRequest httpRequest, OSHttpResponse httpResponse)
+ string request, string path, string param, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
{
try
{
diff --git a/OpenSim/Capabilities/Handlers/WebFetchInventoryDescendents/WebFetchInvDescHandler.cs b/OpenSim/Capabilities/Handlers/WebFetchInventoryDescendents/WebFetchInvDescHandler.cs
index 2dade5b..a086c0e 100644
--- a/OpenSim/Capabilities/Handlers/WebFetchInventoryDescendents/WebFetchInvDescHandler.cs
+++ b/OpenSim/Capabilities/Handlers/WebFetchInventoryDescendents/WebFetchInvDescHandler.cs
@@ -57,7 +57,7 @@ namespace OpenSim.Capabilities.Handlers
m_LibraryService = libService;
}
- public string FetchInventoryDescendentsRequest(string request, string path, string param, OSHttpRequest httpRequest, OSHttpResponse httpResponse)
+ public string FetchInventoryDescendentsRequest(string request, string path, string param, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
{
// lock (m_fetchLock)
// {
diff --git a/OpenSim/Capabilities/LLSDStreamHandler.cs b/OpenSim/Capabilities/LLSDStreamHandler.cs
index 7aaa994..c7c1fc9 100644
--- a/OpenSim/Capabilities/LLSDStreamHandler.cs
+++ b/OpenSim/Capabilities/LLSDStreamHandler.cs
@@ -45,7 +45,7 @@ namespace OpenSim.Framework.Capabilities
}
public override byte[] Handle(string path, Stream request,
- OSHttpRequest httpRequest, OSHttpResponse httpResponse)
+ IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
{
//Encoding encoding = Util.UTF8;
//StreamReader streamReader = new StreamReader(request, false);
--
cgit v1.1
From 319507f5215f5705cbe80d0c468da15ffe778829 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Mon, 5 Dec 2011 21:04:17 +0000
Subject: Add test for not found response from GetTexture cap handler.
Add OpenSim.Region.Capabilities.Handlers.Tests.dll into test suite
---
.../GetTexture/Tests/GetTextureHandlerTests.cs | 63 ++++++++++++++++++++++
1 file changed, 63 insertions(+)
create mode 100644 OpenSim/Capabilities/Handlers/GetTexture/Tests/GetTextureHandlerTests.cs
(limited to 'OpenSim/Capabilities')
diff --git a/OpenSim/Capabilities/Handlers/GetTexture/Tests/GetTextureHandlerTests.cs b/OpenSim/Capabilities/Handlers/GetTexture/Tests/GetTextureHandlerTests.cs
new file mode 100644
index 0000000..fd152c3
--- /dev/null
+++ b/OpenSim/Capabilities/Handlers/GetTexture/Tests/GetTextureHandlerTests.cs
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) Contributors, http://opensimulator.org/
+ * See CONTRIBUTORS.TXT for a full list of copyright holders.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the OpenSimulator Project nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Net;
+using log4net;
+using log4net.Config;
+using NUnit.Framework;
+using OpenMetaverse;
+using OpenSim.Capabilities.Handlers;
+using OpenSim.Framework;
+using OpenSim.Framework.Servers.HttpServer;
+using OpenSim.Region.Framework.Scenes;
+using OpenSim.Tests.Common;
+using OpenSim.Tests.Common.Mock;
+
+namespace OpenSim.Capabilities.Handlers.GetTexture.Tests
+{
+ [TestFixture]
+ public class GetTextureHandlerTests
+ {
+ [Test]
+ public void TestTextureNotFound()
+ {
+ TestHelpers.InMethod();
+
+ // Overkill - we only really need the asset service, not a whole scene.
+ Scene scene = SceneHelpers.SetupScene();
+
+ GetTextureHandler handler = new GetTextureHandler(null, scene.AssetService);
+ TestOSHttpRequest req = new TestOSHttpRequest();
+ TestOSHttpResponse resp = new TestOSHttpResponse();
+ req.Url = new Uri("http://localhost/?texture_id=00000000-0000-1111-9999-000000000012");
+ handler.Handle(null, null, req, resp);
+ Assert.That(resp.StatusCode, Is.EqualTo((int)System.Net.HttpStatusCode.NotFound));
+ }
+ }
+}
\ No newline at end of file
--
cgit v1.1
From 8721841fc3944ce0cdf5ce76297e73f9ed269751 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Tue, 6 Dec 2011 18:37:13 +0000
Subject: Revert "Stop performing the asset save part of baked texture
uploading on the UploadBakedTexture cap asynchronously." This is a possible
cause of the dramatic upswing in "Unable to upload... No handler registered
for LLSD requests..." Needs more investigation.
This reverts commit 1854c52ea3c60d0a47f9793a7f5ec405e15489ca.
---
.../UploadBakedTexture/UploadBakedTextureHandler.cs | 14 +++++---------
1 file changed, 5 insertions(+), 9 deletions(-)
(limited to 'OpenSim/Capabilities')
diff --git a/OpenSim/Capabilities/Handlers/UploadBakedTexture/UploadBakedTextureHandler.cs b/OpenSim/Capabilities/Handlers/UploadBakedTexture/UploadBakedTextureHandler.cs
index e0ccc3c..e3bf8cf 100644
--- a/OpenSim/Capabilities/Handlers/UploadBakedTexture/UploadBakedTextureHandler.cs
+++ b/OpenSim/Capabilities/Handlers/UploadBakedTexture/UploadBakedTextureHandler.cs
@@ -106,7 +106,7 @@ namespace OpenSim.Capabilities.Handlers
}
catch (Exception e)
{
- m_log.Error("[UPLOAD BAKED TEXTURE HANDLER]: " + e.ToString());
+ m_log.Error("[CAPS]: " + e.ToString());
}
return null;
@@ -132,8 +132,6 @@ namespace OpenSim.Capabilities.Handlers
class BakedTextureUploader
{
-// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
-
public event Action OnUpLoad;
private string uploaderPath = String.Empty;
@@ -158,12 +156,10 @@ namespace OpenSim.Capabilities.Handlers
public string uploaderCaps(byte[] data, string path, string param)
{
Action handlerUpLoad = OnUpLoad;
-
- // Don't do this asynchronously, otherwise it's possible for the client to send set appearance information
- // on another thread which might send out avatar updates before the asset has been put into the asset
- // service.
if (handlerUpLoad != null)
- handlerUpLoad(newAssetID, data);
+ {
+ Util.FireAndForget(delegate(object o) { handlerUpLoad(newAssetID, data); });
+ }
string res = String.Empty;
LLSDAssetUploadComplete uploadComplete = new LLSDAssetUploadComplete();
@@ -175,7 +171,7 @@ namespace OpenSim.Capabilities.Handlers
httpListener.RemoveStreamHandler("POST", uploaderPath);
-// m_log.DebugFormat("[BAKED TEXTURE UPLOADER]: baked texture upload completed for {0}", newAssetID);
+ // m_log.InfoFormat("[CAPS] baked texture upload completed for {0}",newAssetID);
return res;
}
--
cgit v1.1
From 8e542cfa03f9368368a0f73fbcff0d54622b5588 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Tue, 6 Dec 2011 21:42:56 +0000
Subject: Stop accidentally setting up the UploadTexture caps handler with the
same url for all users
This meant that if a user exited the region, the UploadTexture handler would be effectively removed for everyone, causing subsequent failures.
This hopefully resolves the recent UploadTexture LLSD problems
This was a regression in 5640f2e (Thu Dec 1 23:24:15 2011 +0000)
---
.../Handlers/UploadBakedTexture/UploadBakedTextureHandler.cs | 2 --
1 file changed, 2 deletions(-)
(limited to 'OpenSim/Capabilities')
diff --git a/OpenSim/Capabilities/Handlers/UploadBakedTexture/UploadBakedTextureHandler.cs b/OpenSim/Capabilities/Handlers/UploadBakedTexture/UploadBakedTextureHandler.cs
index e3bf8cf..b7ca703 100644
--- a/OpenSim/Capabilities/Handlers/UploadBakedTexture/UploadBakedTextureHandler.cs
+++ b/OpenSim/Capabilities/Handlers/UploadBakedTexture/UploadBakedTextureHandler.cs
@@ -77,8 +77,6 @@ namespace OpenSim.Capabilities.Handlers
{
try
{
-// m_log.Debug("[CAPS]: UploadBakedTexture Request in region: " + m_regionName);
-
string capsBase = "/CAPS/" + m_HostCapsObj.CapsObjectPath;
string uploaderPath = Util.RandomClass.Next(5000, 8000).ToString("0000");
--
cgit v1.1