diff options
author | Diva Canto | 2014-05-07 19:38:33 -0700 |
---|---|---|
committer | Diva Canto | 2014-05-07 19:38:33 -0700 |
commit | a845c1a893a203f1a9bc38dc754a6f94e4c02ea5 (patch) | |
tree | e2b9118deb856f87444b2062fa78e4adca900d42 /OpenSim | |
parent | Delete extraneous console message in the Configger. (diff) | |
download | opensim-SC_OLD-a845c1a893a203f1a9bc38dc754a6f94e4c02ea5.zip opensim-SC_OLD-a845c1a893a203f1a9bc38dc754a6f94e4c02ea5.tar.gz opensim-SC_OLD-a845c1a893a203f1a9bc38dc754a6f94e4c02ea5.tar.bz2 opensim-SC_OLD-a845c1a893a203f1a9bc38dc754a6f94e4c02ea5.tar.xz |
Finished implementing redirects in GetTexture.
Diffstat (limited to 'OpenSim')
4 files changed, 18 insertions, 9 deletions
diff --git a/OpenSim/Capabilities/Handlers/GetTexture/GetTextureHandler.cs b/OpenSim/Capabilities/Handlers/GetTexture/GetTextureHandler.cs index 7b3124a..4dfa847 100644 --- a/OpenSim/Capabilities/Handlers/GetTexture/GetTextureHandler.cs +++ b/OpenSim/Capabilities/Handlers/GetTexture/GetTextureHandler.cs | |||
@@ -56,12 +56,15 @@ namespace OpenSim.Capabilities.Handlers | |||
56 | public const string DefaultFormat = "x-j2c"; | 56 | public const string DefaultFormat = "x-j2c"; |
57 | 57 | ||
58 | // TODO: Change this to a config option | 58 | // TODO: Change this to a config option |
59 | const string REDIRECT_URL = null; | 59 | private string m_RedirectURL = null; |
60 | 60 | ||
61 | public GetTextureHandler(string path, IAssetService assService, string name, string description) | 61 | public GetTextureHandler(string path, IAssetService assService, string name, string description, string redirectURL) |
62 | : base("GET", path, name, description) | 62 | : base("GET", path, name, description) |
63 | { | 63 | { |
64 | m_assetService = assService; | 64 | m_assetService = assService; |
65 | m_RedirectURL = redirectURL; | ||
66 | if (!m_RedirectURL.EndsWith("/")) | ||
67 | m_RedirectURL += "/"; | ||
65 | } | 68 | } |
66 | 69 | ||
67 | protected override byte[] ProcessRequest(string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) | 70 | protected override byte[] ProcessRequest(string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) |
@@ -134,7 +137,7 @@ namespace OpenSim.Capabilities.Handlers | |||
134 | if (format != DefaultFormat) | 137 | if (format != DefaultFormat) |
135 | fullID = fullID + "-" + format; | 138 | fullID = fullID + "-" + format; |
136 | 139 | ||
137 | if (!String.IsNullOrEmpty(REDIRECT_URL)) | 140 | if (!String.IsNullOrEmpty(m_RedirectURL)) |
138 | { | 141 | { |
139 | // Only try to fetch locally cached textures. Misses are redirected | 142 | // Only try to fetch locally cached textures. Misses are redirected |
140 | texture = m_assetService.GetCached(fullID); | 143 | texture = m_assetService.GetCached(fullID); |
@@ -150,8 +153,9 @@ namespace OpenSim.Capabilities.Handlers | |||
150 | } | 153 | } |
151 | else | 154 | else |
152 | { | 155 | { |
153 | string textureUrl = REDIRECT_URL + textureID.ToString(); | 156 | string textureUrl = m_RedirectURL + textureID.ToString(); |
154 | m_log.Debug("[GETTEXTURE]: Redirecting texture request to " + textureUrl); | 157 | m_log.Debug("[GETTEXTURE]: Redirecting texture request to " + textureUrl); |
158 | httpResponse.StatusCode = (int)OSHttpStatusCode.RedirectMovedPermanently; | ||
155 | httpResponse.RedirectLocation = textureUrl; | 159 | httpResponse.RedirectLocation = textureUrl; |
156 | return true; | 160 | return true; |
157 | } | 161 | } |
diff --git a/OpenSim/Capabilities/Handlers/GetTexture/GetTextureServerConnector.cs b/OpenSim/Capabilities/Handlers/GetTexture/GetTextureServerConnector.cs index 71cf033..fa0b228 100644 --- a/OpenSim/Capabilities/Handlers/GetTexture/GetTextureServerConnector.cs +++ b/OpenSim/Capabilities/Handlers/GetTexture/GetTextureServerConnector.cs | |||
@@ -62,8 +62,10 @@ namespace OpenSim.Capabilities.Handlers | |||
62 | if (m_AssetService == null) | 62 | if (m_AssetService == null) |
63 | throw new Exception(String.Format("Failed to load AssetService from {0}; config is {1}", assetService, m_ConfigName)); | 63 | throw new Exception(String.Format("Failed to load AssetService from {0}; config is {1}", assetService, m_ConfigName)); |
64 | 64 | ||
65 | string rurl = serverConfig.GetString("GetTextureRedirectURL"); | ||
66 | ; | ||
65 | server.AddStreamHandler( | 67 | server.AddStreamHandler( |
66 | new GetTextureHandler("/CAPS/GetTexture/" /*+ UUID.Random() */, m_AssetService, "GetTexture", null)); | 68 | new GetTextureHandler("/CAPS/GetTexture/" /*+ UUID.Random() */, m_AssetService, "GetTexture", null, rurl)); |
67 | } | 69 | } |
68 | } | 70 | } |
69 | } \ No newline at end of file | 71 | } \ No newline at end of file |
diff --git a/OpenSim/Capabilities/Handlers/GetTexture/Tests/GetTextureHandlerTests.cs b/OpenSim/Capabilities/Handlers/GetTexture/Tests/GetTextureHandlerTests.cs index d4d6d10..8ffafa4 100644 --- a/OpenSim/Capabilities/Handlers/GetTexture/Tests/GetTextureHandlerTests.cs +++ b/OpenSim/Capabilities/Handlers/GetTexture/Tests/GetTextureHandlerTests.cs | |||
@@ -52,7 +52,7 @@ namespace OpenSim.Capabilities.Handlers.GetTexture.Tests | |||
52 | // Overkill - we only really need the asset service, not a whole scene. | 52 | // Overkill - we only really need the asset service, not a whole scene. |
53 | Scene scene = new SceneHelpers().SetupScene(); | 53 | Scene scene = new SceneHelpers().SetupScene(); |
54 | 54 | ||
55 | GetTextureHandler handler = new GetTextureHandler(null, scene.AssetService, "TestGetTexture", null); | 55 | GetTextureHandler handler = new GetTextureHandler(null, scene.AssetService, "TestGetTexture", null, null); |
56 | TestOSHttpRequest req = new TestOSHttpRequest(); | 56 | TestOSHttpRequest req = new TestOSHttpRequest(); |
57 | TestOSHttpResponse resp = new TestOSHttpResponse(); | 57 | TestOSHttpResponse resp = new TestOSHttpResponse(); |
58 | req.Url = new Uri("http://localhost/?texture_id=00000000-0000-1111-9999-000000000012"); | 58 | req.Url = new Uri("http://localhost/?texture_id=00000000-0000-1111-9999-000000000012"); |
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs index 54cf285..bb932f2 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs | |||
@@ -63,7 +63,7 @@ namespace OpenSim.Region.ClientStack.Linden | |||
63 | private bool m_Enabled = false; | 63 | private bool m_Enabled = false; |
64 | 64 | ||
65 | // TODO: Change this to a config option | 65 | // TODO: Change this to a config option |
66 | const string REDIRECT_URL = null; | 66 | private string m_RedirectURL = null; |
67 | 67 | ||
68 | private string m_URL; | 68 | private string m_URL; |
69 | 69 | ||
@@ -78,7 +78,10 @@ namespace OpenSim.Region.ClientStack.Linden | |||
78 | m_URL = config.GetString("Cap_GetTexture", string.Empty); | 78 | m_URL = config.GetString("Cap_GetTexture", string.Empty); |
79 | // Cap doesn't exist | 79 | // Cap doesn't exist |
80 | if (m_URL != string.Empty) | 80 | if (m_URL != string.Empty) |
81 | { | ||
81 | m_Enabled = true; | 82 | m_Enabled = true; |
83 | m_RedirectURL = config.GetString("GetTextureRedirectURL"); | ||
84 | } | ||
82 | } | 85 | } |
83 | 86 | ||
84 | public void AddRegion(Scene s) | 87 | public void AddRegion(Scene s) |
@@ -132,14 +135,14 @@ namespace OpenSim.Region.ClientStack.Linden | |||
132 | // m_log.DebugFormat("[GETTEXTURE]: /CAPS/{0} in region {1}", capID, m_scene.RegionInfo.RegionName); | 135 | // m_log.DebugFormat("[GETTEXTURE]: /CAPS/{0} in region {1}", capID, m_scene.RegionInfo.RegionName); |
133 | caps.RegisterHandler( | 136 | caps.RegisterHandler( |
134 | "GetTexture", | 137 | "GetTexture", |
135 | new GetTextureHandler("/CAPS/" + capID + "/", m_assetService, "GetTexture", agentID.ToString())); | 138 | new GetTextureHandler("/CAPS/" + capID + "/", m_assetService, "GetTexture", agentID.ToString(), m_RedirectURL)); |
136 | } | 139 | } |
137 | else | 140 | else |
138 | { | 141 | { |
139 | // m_log.DebugFormat("[GETTEXTURE]: {0} in region {1}", m_URL, m_scene.RegionInfo.RegionName); | 142 | // m_log.DebugFormat("[GETTEXTURE]: {0} in region {1}", m_URL, m_scene.RegionInfo.RegionName); |
140 | IExternalCapsModule handler = m_scene.RequestModuleInterface<IExternalCapsModule>(); | 143 | IExternalCapsModule handler = m_scene.RequestModuleInterface<IExternalCapsModule>(); |
141 | if (handler != null) | 144 | if (handler != null) |
142 | handler.RegisterExternalUserCapsHandler(agentID,caps,"GetTexture",m_URL); | 145 | handler.RegisterExternalUserCapsHandler(agentID,caps,"GetTexture", m_URL); |
143 | else | 146 | else |
144 | caps.RegisterHandler("GetTexture", m_URL); | 147 | caps.RegisterHandler("GetTexture", m_URL); |
145 | } | 148 | } |