diff options
author | David Walter Seikel | 2016-11-03 21:44:39 +1000 |
---|---|---|
committer | David Walter Seikel | 2016-11-03 21:44:39 +1000 |
commit | 134f86e8d5c414409631b25b8c6f0ee45fbd8631 (patch) | |
tree | 216b89d3fb89acfb81be1e440c25c41ab09fa96d /OpenSim/Region/CoreModules/Scripting/LoadImageURL | |
parent | More changing to production grid. Double oops. (diff) | |
download | opensim-SC_OLD-134f86e8d5c414409631b25b8c6f0ee45fbd8631.zip opensim-SC_OLD-134f86e8d5c414409631b25b8c6f0ee45fbd8631.tar.gz opensim-SC_OLD-134f86e8d5c414409631b25b8c6f0ee45fbd8631.tar.bz2 opensim-SC_OLD-134f86e8d5c414409631b25b8c6f0ee45fbd8631.tar.xz |
Initial update to OpenSim 0.8.2.1 source code.
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/CoreModules/Scripting/LoadImageURL/LoadImageURLModule.cs | 57 |
1 files changed, 40 insertions, 17 deletions
diff --git a/OpenSim/Region/CoreModules/Scripting/LoadImageURL/LoadImageURLModule.cs b/OpenSim/Region/CoreModules/Scripting/LoadImageURL/LoadImageURLModule.cs index 65737fa..d45962f 100644 --- a/OpenSim/Region/CoreModules/Scripting/LoadImageURL/LoadImageURLModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/LoadImageURL/LoadImageURLModule.cs | |||
@@ -32,6 +32,7 @@ using System.Net; | |||
32 | using Nini.Config; | 32 | using Nini.Config; |
33 | using OpenMetaverse; | 33 | using OpenMetaverse; |
34 | using OpenMetaverse.Imaging; | 34 | using OpenMetaverse.Imaging; |
35 | using OpenSim.Framework; | ||
35 | using OpenSim.Region.CoreModules.Scripting.DynamicTexture; | 36 | using OpenSim.Region.CoreModules.Scripting.DynamicTexture; |
36 | using OpenSim.Region.Framework.Interfaces; | 37 | using OpenSim.Region.Framework.Interfaces; |
37 | using OpenSim.Region.Framework.Scenes; | 38 | using OpenSim.Region.Framework.Scenes; |
@@ -50,6 +51,7 @@ namespace OpenSim.Region.CoreModules.Scripting.LoadImageURL | |||
50 | private Scene m_scene; | 51 | private Scene m_scene; |
51 | private IDynamicTextureManager m_textureManager; | 52 | private IDynamicTextureManager m_textureManager; |
52 | 53 | ||
54 | private OutboundUrlFilter m_outboundUrlFilter; | ||
53 | private string m_proxyurl = ""; | 55 | private string m_proxyurl = ""; |
54 | private string m_proxyexcepts = ""; | 56 | private string m_proxyexcepts = ""; |
55 | 57 | ||
@@ -88,8 +90,7 @@ namespace OpenSim.Region.CoreModules.Scripting.LoadImageURL | |||
88 | 90 | ||
89 | public bool AsyncConvertUrl(UUID id, string url, string extraParams) | 91 | public bool AsyncConvertUrl(UUID id, string url, string extraParams) |
90 | { | 92 | { |
91 | MakeHttpRequest(url, id); | 93 | return MakeHttpRequest(url, id); |
92 | return true; | ||
93 | } | 94 | } |
94 | 95 | ||
95 | public bool AsyncConvertData(UUID id, string bodyData, string extraParams) | 96 | public bool AsyncConvertData(UUID id, string bodyData, string extraParams) |
@@ -110,6 +111,7 @@ namespace OpenSim.Region.CoreModules.Scripting.LoadImageURL | |||
110 | 111 | ||
111 | public void Initialise(IConfigSource config) | 112 | public void Initialise(IConfigSource config) |
112 | { | 113 | { |
114 | m_outboundUrlFilter = new OutboundUrlFilter("Script dynamic texture image module", config); | ||
113 | m_proxyurl = config.Configs["Startup"].GetString("HttpProxy"); | 115 | m_proxyurl = config.Configs["Startup"].GetString("HttpProxy"); |
114 | m_proxyexcepts = config.Configs["Startup"].GetString("HttpProxyExceptions"); | 116 | m_proxyexcepts = config.Configs["Startup"].GetString("HttpProxyExceptions"); |
115 | } | 117 | } |
@@ -157,13 +159,17 @@ namespace OpenSim.Region.CoreModules.Scripting.LoadImageURL | |||
157 | 159 | ||
158 | #endregion | 160 | #endregion |
159 | 161 | ||
160 | private void MakeHttpRequest(string url, UUID requestID) | 162 | private bool MakeHttpRequest(string url, UUID requestID) |
161 | { | 163 | { |
162 | WebRequest request = HttpWebRequest.Create(url); | 164 | if (!m_outboundUrlFilter.CheckAllowed(new Uri(url))) |
165 | return false; | ||
166 | |||
167 | HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); | ||
168 | request.AllowAutoRedirect = false; | ||
163 | 169 | ||
164 | if (m_proxyurl != null && m_proxyurl.Length > 0) | 170 | if (!string.IsNullOrEmpty(m_proxyurl)) |
165 | { | 171 | { |
166 | if (m_proxyexcepts != null && m_proxyexcepts.Length > 0) | 172 | if (!string.IsNullOrEmpty(m_proxyexcepts)) |
167 | { | 173 | { |
168 | string[] elist = m_proxyexcepts.Split(';'); | 174 | string[] elist = m_proxyexcepts.Split(';'); |
169 | request.Proxy = new WebProxy(m_proxyurl, true, elist); | 175 | request.Proxy = new WebProxy(m_proxyurl, true, elist); |
@@ -174,12 +180,14 @@ namespace OpenSim.Region.CoreModules.Scripting.LoadImageURL | |||
174 | } | 180 | } |
175 | } | 181 | } |
176 | 182 | ||
177 | RequestState state = new RequestState((HttpWebRequest) request, requestID); | 183 | RequestState state = new RequestState(request, requestID); |
178 | // IAsyncResult result = request.BeginGetResponse(new AsyncCallback(HttpRequestReturn), state); | 184 | // IAsyncResult result = request.BeginGetResponse(new AsyncCallback(HttpRequestReturn), state); |
179 | request.BeginGetResponse(new AsyncCallback(HttpRequestReturn), state); | 185 | request.BeginGetResponse(new AsyncCallback(HttpRequestReturn), state); |
180 | 186 | ||
181 | TimeSpan t = (DateTime.UtcNow - new DateTime(1970, 1, 1)); | 187 | TimeSpan t = (DateTime.UtcNow - new DateTime(1970, 1, 1)); |
182 | state.TimeOfRequest = (int) t.TotalSeconds; | 188 | state.TimeOfRequest = (int) t.TotalSeconds; |
189 | |||
190 | return true; | ||
183 | } | 191 | } |
184 | 192 | ||
185 | private void HttpRequestReturn(IAsyncResult result) | 193 | private void HttpRequestReturn(IAsyncResult result) |
@@ -195,10 +203,11 @@ namespace OpenSim.Region.CoreModules.Scripting.LoadImageURL | |||
195 | Stream stream = null; | 203 | Stream stream = null; |
196 | byte[] imageJ2000 = new byte[0]; | 204 | byte[] imageJ2000 = new byte[0]; |
197 | Size newSize = new Size(0, 0); | 205 | Size newSize = new Size(0, 0); |
206 | HttpWebResponse response = null; | ||
198 | 207 | ||
199 | try | 208 | try |
200 | { | 209 | { |
201 | HttpWebResponse response = (HttpWebResponse)request.EndGetResponse(result); | 210 | response = (HttpWebResponse)request.EndGetResponse(result); |
202 | if (response != null && response.StatusCode == HttpStatusCode.OK) | 211 | if (response != null && response.StatusCode == HttpStatusCode.OK) |
203 | { | 212 | { |
204 | stream = response.GetResponseStream(); | 213 | stream = response.GetResponseStream(); |
@@ -262,18 +271,32 @@ namespace OpenSim.Region.CoreModules.Scripting.LoadImageURL | |||
262 | finally | 271 | finally |
263 | { | 272 | { |
264 | if (stream != null) | 273 | if (stream != null) |
265 | { | ||
266 | stream.Close(); | 274 | stream.Close(); |
267 | } | ||
268 | } | ||
269 | 275 | ||
270 | m_log.DebugFormat("[LOADIMAGEURLMODULE]: Returning {0} bytes of image data for request {1}", | 276 | if (response != null) |
271 | imageJ2000.Length, state.RequestID); | 277 | response.Close(); |
272 | 278 | ||
273 | m_textureManager.ReturnData( | 279 | if ( |
274 | state.RequestID, | 280 | response.StatusCode == HttpStatusCode.MovedPermanently |
275 | new OpenSim.Region.CoreModules.Scripting.DynamicTexture.DynamicTexture( | 281 | || response.StatusCode == HttpStatusCode.Found |
276 | request.RequestUri, null, imageJ2000, newSize, false)); | 282 | || response.StatusCode == HttpStatusCode.SeeOther |
283 | || response.StatusCode == HttpStatusCode.TemporaryRedirect) | ||
284 | { | ||
285 | string redirectedUrl = response.Headers["Location"]; | ||
286 | |||
287 | MakeHttpRequest(redirectedUrl, state.RequestID); | ||
288 | } | ||
289 | else | ||
290 | { | ||
291 | m_log.DebugFormat("[LOADIMAGEURLMODULE]: Returning {0} bytes of image data for request {1}", | ||
292 | imageJ2000.Length, state.RequestID); | ||
293 | |||
294 | m_textureManager.ReturnData( | ||
295 | state.RequestID, | ||
296 | new OpenSim.Region.CoreModules.Scripting.DynamicTexture.DynamicTexture( | ||
297 | request.RequestUri, null, imageJ2000, newSize, false)); | ||
298 | } | ||
299 | } | ||
277 | } | 300 | } |
278 | 301 | ||
279 | #region Nested type: RequestState | 302 | #region Nested type: RequestState |