diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Framework/Servers/CachedGetAssetStreamHandler.cs | 4 | ||||
-rw-r--r-- | OpenSim/Framework/Servers/GetAssetStreamHandler.cs | 14 | ||||
-rw-r--r-- | OpenSim/Framework/Servers/HttpServer/BaseRequestHandler.cs | 4 | ||||
-rw-r--r-- | OpenSim/Framework/Servers/Tests/GetAssetStreamHandlerTests.cs | 42 | ||||
-rw-r--r-- | prebuild.xml | 1 |
5 files changed, 57 insertions, 8 deletions
diff --git a/OpenSim/Framework/Servers/CachedGetAssetStreamHandler.cs b/OpenSim/Framework/Servers/CachedGetAssetStreamHandler.cs index 39041df..fb217d1 100644 --- a/OpenSim/Framework/Servers/CachedGetAssetStreamHandler.cs +++ b/OpenSim/Framework/Servers/CachedGetAssetStreamHandler.cs | |||
@@ -48,7 +48,7 @@ namespace OpenSim.Framework.Servers | |||
48 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 48 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
49 | 49 | ||
50 | // private OpenAsset_Main m_assetManager; | 50 | // private OpenAsset_Main m_assetManager; |
51 | private IAssetCache m_assetProvider; | 51 | private readonly IAssetCache m_assetProvider; |
52 | 52 | ||
53 | /// <summary> | 53 | /// <summary> |
54 | /// Constructor. | 54 | /// Constructor. |
@@ -58,7 +58,7 @@ namespace OpenSim.Framework.Servers | |||
58 | public CachedGetAssetStreamHandler(IAssetCache assetProvider) | 58 | public CachedGetAssetStreamHandler(IAssetCache assetProvider) |
59 | : base("GET", "/assets") | 59 | : base("GET", "/assets") |
60 | { | 60 | { |
61 | m_log.Info("[REST]: In Get Request"); | 61 | // m_log.Info("[REST]: In Get Request"); |
62 | // m_assetManager = assetManager; | 62 | // m_assetManager = assetManager; |
63 | m_assetProvider = assetProvider; | 63 | m_assetProvider = assetProvider; |
64 | } | 64 | } |
diff --git a/OpenSim/Framework/Servers/GetAssetStreamHandler.cs b/OpenSim/Framework/Servers/GetAssetStreamHandler.cs index c935d2a..1b87496 100644 --- a/OpenSim/Framework/Servers/GetAssetStreamHandler.cs +++ b/OpenSim/Framework/Servers/GetAssetStreamHandler.cs | |||
@@ -48,7 +48,7 @@ namespace OpenSim.Framework.Servers | |||
48 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 48 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
49 | 49 | ||
50 | // private OpenAsset_Main m_assetManager; | 50 | // private OpenAsset_Main m_assetManager; |
51 | private IAssetDataPlugin m_assetProvider; | 51 | private readonly IAssetDataPlugin m_assetProvider; |
52 | 52 | ||
53 | /// <summary> | 53 | /// <summary> |
54 | /// Constructor. | 54 | /// Constructor. |
@@ -58,7 +58,7 @@ namespace OpenSim.Framework.Servers | |||
58 | public GetAssetStreamHandler(IAssetDataPlugin assetProvider) | 58 | public GetAssetStreamHandler(IAssetDataPlugin assetProvider) |
59 | : base("GET", "/assets") | 59 | : base("GET", "/assets") |
60 | { | 60 | { |
61 | m_log.Info("[REST]: In Get Request"); | 61 | // m_log.Info("[REST]: In Get Request"); |
62 | // m_assetManager = assetManager; | 62 | // m_assetManager = assetManager; |
63 | m_assetProvider = assetProvider; | 63 | m_assetProvider = assetProvider; |
64 | } | 64 | } |
@@ -66,10 +66,9 @@ namespace OpenSim.Framework.Servers | |||
66 | public override byte[] Handle(string path, Stream request, | 66 | public override byte[] Handle(string path, Stream request, |
67 | OSHttpRequest httpRequest, OSHttpResponse httpResponse) | 67 | OSHttpRequest httpRequest, OSHttpResponse httpResponse) |
68 | { | 68 | { |
69 | string param = GetParam(path); | ||
70 | byte[] result = new byte[] { }; | 69 | byte[] result = new byte[] { }; |
71 | 70 | ||
72 | string[] p = param.Split(new char[] { '/', '?', '&' }, StringSplitOptions.RemoveEmptyEntries); | 71 | string[] p = SplitParams(path); |
73 | 72 | ||
74 | if (p.Length > 0) | 73 | if (p.Length > 0) |
75 | { | 74 | { |
@@ -127,6 +126,13 @@ namespace OpenSim.Framework.Servers | |||
127 | return result; | 126 | return result; |
128 | } | 127 | } |
129 | 128 | ||
129 | public string[] SplitParams(string path) | ||
130 | { | ||
131 | string param = GetParam(path); | ||
132 | |||
133 | return param.Split(new char[] { '/', '?', '&' }, StringSplitOptions.RemoveEmptyEntries); | ||
134 | } | ||
135 | |||
130 | // private byte[] ProcessOutgoingAssetData(byte[] assetData) | 136 | // private byte[] ProcessOutgoingAssetData(byte[] assetData) |
131 | // { | 137 | // { |
132 | // string data = Encoding.ASCII.GetString(assetData); | 138 | // string data = Encoding.ASCII.GetString(assetData); |
diff --git a/OpenSim/Framework/Servers/HttpServer/BaseRequestHandler.cs b/OpenSim/Framework/Servers/HttpServer/BaseRequestHandler.cs index 9334972..5ad4520 100644 --- a/OpenSim/Framework/Servers/HttpServer/BaseRequestHandler.cs +++ b/OpenSim/Framework/Servers/HttpServer/BaseRequestHandler.cs | |||
@@ -29,7 +29,7 @@ using System; | |||
29 | 29 | ||
30 | namespace OpenSim.Framework.Servers.HttpServer | 30 | namespace OpenSim.Framework.Servers.HttpServer |
31 | { | 31 | { |
32 | public class BaseRequestHandler | 32 | public abstract class BaseRequestHandler |
33 | { | 33 | { |
34 | public virtual string ContentType | 34 | public virtual string ContentType |
35 | { | 35 | { |
@@ -56,7 +56,7 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
56 | get { return m_path; } | 56 | get { return m_path; } |
57 | } | 57 | } |
58 | 58 | ||
59 | protected string GetParam(string path) | 59 | public string GetParam(string path) |
60 | { | 60 | { |
61 | try | 61 | try |
62 | { | 62 | { |
diff --git a/OpenSim/Framework/Servers/Tests/GetAssetStreamHandlerTests.cs b/OpenSim/Framework/Servers/Tests/GetAssetStreamHandlerTests.cs new file mode 100644 index 0000000..d399274 --- /dev/null +++ b/OpenSim/Framework/Servers/Tests/GetAssetStreamHandlerTests.cs | |||
@@ -0,0 +1,42 @@ | |||
1 | using System; | ||
2 | using System.Collections.Generic; | ||
3 | using System.Text; | ||
4 | using NUnit.Framework; | ||
5 | |||
6 | namespace OpenSim.Framework.Servers.Tests | ||
7 | { | ||
8 | [TestFixture] | ||
9 | public class GetAssetStreamHandlerTests | ||
10 | { | ||
11 | [Test] | ||
12 | public void TestConstructor() | ||
13 | { | ||
14 | GetAssetStreamHandler handler = new GetAssetStreamHandler( null ); | ||
15 | } | ||
16 | |||
17 | [Test] | ||
18 | public void TestGetParams() | ||
19 | { | ||
20 | GetAssetStreamHandler handler = new GetAssetStreamHandler(null); | ||
21 | |||
22 | Assert.AreEqual("", handler.GetParam("/assets")); | ||
23 | Assert.AreEqual("/", handler.GetParam("/assets/")); | ||
24 | Assert.AreEqual("/a", handler.GetParam("/assets/a")); | ||
25 | Assert.AreEqual("/b/", handler.GetParam("/assets/b/")); | ||
26 | Assert.AreEqual("/c/d", handler.GetParam("/assets/c/d")); | ||
27 | Assert.AreEqual("/e/f/", handler.GetParam("/assets/e/f/")); | ||
28 | } | ||
29 | |||
30 | [Test] | ||
31 | public void TestSplitParams() | ||
32 | { | ||
33 | GetAssetStreamHandler handler = new GetAssetStreamHandler(null); | ||
34 | |||
35 | Assert.AreEqual(new string[] { }, handler.SplitParams("/assets"), "Failed on empty params."); | ||
36 | Assert.AreEqual(new string[] { }, handler.SplitParams("/assets/"), "Failed on single slash."); | ||
37 | Assert.AreEqual(new string[] { "a" }, handler.SplitParams("/assets/a"), "Failed on first segment."); | ||
38 | Assert.AreEqual(new string[] { "b" }, handler.SplitParams("/assets/b/"), "Failed on second slash."); | ||
39 | } | ||
40 | |||
41 | } | ||
42 | } | ||
diff --git a/prebuild.xml b/prebuild.xml index 95be0bc..5e51ff6 100644 --- a/prebuild.xml +++ b/prebuild.xml | |||
@@ -3197,6 +3197,7 @@ | |||
3197 | 3197 | ||
3198 | <ReferencePath>../../../../bin/</ReferencePath> | 3198 | <ReferencePath>../../../../bin/</ReferencePath> |
3199 | <Reference name="System"/> | 3199 | <Reference name="System"/> |
3200 | <Reference name="OpenSim.Data"/> | ||
3200 | <Reference name="OpenSim.Framework"/> | 3201 | <Reference name="OpenSim.Framework"/> |
3201 | <Reference name="OpenSim.Framework.Servers"/> | 3202 | <Reference name="OpenSim.Framework.Servers"/> |
3202 | <Reference name="OpenSim.Framework.Servers.HttpServer"/> | 3203 | <Reference name="OpenSim.Framework.Servers.HttpServer"/> |