aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--OpenSim/Server/Handlers/Asset/AssetServerConnector.cs4
-rw-r--r--OpenSim/Server/Handlers/Asset/AssetServerGetHandler.cs21
2 files changed, 21 insertions, 4 deletions
diff --git a/OpenSim/Server/Handlers/Asset/AssetServerConnector.cs b/OpenSim/Server/Handlers/Asset/AssetServerConnector.cs
index df9a51b..ab81dd6 100644
--- a/OpenSim/Server/Handlers/Asset/AssetServerConnector.cs
+++ b/OpenSim/Server/Handlers/Asset/AssetServerConnector.cs
@@ -70,6 +70,8 @@ namespace OpenSim.Server.Handlers.Asset
70 bool allowDelete = serverConfig.GetBoolean("AllowRemoteDelete", false); 70 bool allowDelete = serverConfig.GetBoolean("AllowRemoteDelete", false);
71 bool allowDeleteAllTypes = serverConfig.GetBoolean("AllowRemoteDeleteAllTypes", false); 71 bool allowDeleteAllTypes = serverConfig.GetBoolean("AllowRemoteDeleteAllTypes", false);
72 72
73 string redirectURL = serverConfig.GetString("RedirectURL", string.Empty);
74
73 AllowedRemoteDeleteTypes allowedRemoteDeleteTypes; 75 AllowedRemoteDeleteTypes allowedRemoteDeleteTypes;
74 76
75 if (!allowDelete) 77 if (!allowDelete)
@@ -86,7 +88,7 @@ namespace OpenSim.Server.Handlers.Asset
86 88
87 IServiceAuth auth = ServiceAuth.Create(config, m_ConfigName); 89 IServiceAuth auth = ServiceAuth.Create(config, m_ConfigName);
88 90
89 server.AddStreamHandler(new AssetServerGetHandler(m_AssetService, auth)); 91 server.AddStreamHandler(new AssetServerGetHandler(m_AssetService, auth, redirectURL));
90 server.AddStreamHandler(new AssetServerPostHandler(m_AssetService, auth)); 92 server.AddStreamHandler(new AssetServerPostHandler(m_AssetService, auth));
91 server.AddStreamHandler(new AssetServerDeleteHandler(m_AssetService, allowedRemoteDeleteTypes, auth)); 93 server.AddStreamHandler(new AssetServerDeleteHandler(m_AssetService, allowedRemoteDeleteTypes, auth));
92 server.AddStreamHandler(new AssetsExistHandler(m_AssetService)); 94 server.AddStreamHandler(new AssetsExistHandler(m_AssetService));
diff --git a/OpenSim/Server/Handlers/Asset/AssetServerGetHandler.cs b/OpenSim/Server/Handlers/Asset/AssetServerGetHandler.cs
index 500ec50..91c5c54 100644
--- a/OpenSim/Server/Handlers/Asset/AssetServerGetHandler.cs
+++ b/OpenSim/Server/Handlers/Asset/AssetServerGetHandler.cs
@@ -48,6 +48,7 @@ namespace OpenSim.Server.Handlers.Asset
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 IAssetService m_AssetService; 50 private IAssetService m_AssetService;
51 private string m_RedirectURL;
51 52
52 public AssetServerGetHandler(IAssetService service) : 53 public AssetServerGetHandler(IAssetService service) :
53 base("GET", "/assets") 54 base("GET", "/assets")
@@ -55,10 +56,13 @@ namespace OpenSim.Server.Handlers.Asset
55 m_AssetService = service; 56 m_AssetService = service;
56 } 57 }
57 58
58 public AssetServerGetHandler(IAssetService service, IServiceAuth auth) : 59 public AssetServerGetHandler(IAssetService service, IServiceAuth auth, string redirectURL) :
59 base("GET", "/assets", auth) 60 base("GET", "/assets", auth)
60 { 61 {
61 m_AssetService = service; 62 m_AssetService = service;
63 m_RedirectURL = redirectURL;
64 if (!m_RedirectURL.EndsWith("/"))
65 m_RedirectURL = m_RedirectURL.TrimEnd('/');
62 } 66 }
63 67
64 protected override byte[] ProcessRequest(string path, Stream request, 68 protected override byte[] ProcessRequest(string path, Stream request,
@@ -71,9 +75,10 @@ namespace OpenSim.Server.Handlers.Asset
71 if (p.Length == 0) 75 if (p.Length == 0)
72 return result; 76 return result;
73 77
78 string id = string.Empty;
74 if (p.Length > 1) 79 if (p.Length > 1)
75 { 80 {
76 string id = p[0]; 81 id = p[0];
77 string cmd = p[1]; 82 string cmd = p[1];
78 83
79 if (cmd == "data") 84 if (cmd == "data")
@@ -124,7 +129,7 @@ namespace OpenSim.Server.Handlers.Asset
124 { 129 {
125 // Get the entire asset (metadata + data) 130 // Get the entire asset (metadata + data)
126 131
127 string id = p[0]; 132 id = p[0];
128 AssetBase asset = m_AssetService.Get(id); 133 AssetBase asset = m_AssetService.Get(id);
129 134
130 if (asset != null) 135 if (asset != null)
@@ -151,6 +156,16 @@ namespace OpenSim.Server.Handlers.Asset
151 result = new byte[0]; 156 result = new byte[0];
152 } 157 }
153 158
159 if (httpResponse.StatusCode == (int)HttpStatusCode.NotFound && !string.IsNullOrEmpty(m_RedirectURL) && !string.IsNullOrEmpty(id))
160 {
161 httpResponse.StatusCode = (int)HttpStatusCode.Redirect;
162 string rurl = m_RedirectURL;
163 if (!path.StartsWith("/"))
164 rurl += "/";
165 rurl += path;
166 httpResponse.AddHeader("Location", rurl);
167 m_log.DebugFormat("[ASSET GET HANDLER]: Asset not found, redirecting to {0} ({1})", rurl, httpResponse.StatusCode);
168 }
154 return result; 169 return result;
155 } 170 }
156 } 171 }