From a6b21a3b83d471eabacb92c9c2d9a575e4824d5d Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Fri, 6 Feb 2009 21:56:50 +0000 Subject: * minor: Apply second patch from http://opensimulator.org/mantis/view.php?id=3089 * This adds more explanation for the new proxy settings in OpenSim.ini.example * Also does some formatting correction * I did some additional reformatting on top of that --- .../Scripting/HttpRequest/ScriptsHttpRequests.cs | 33 +++++++++++++--------- .../Scripting/LoadImageURL/LoadImageURLModule.cs | 32 ++++++++++++--------- 2 files changed, 37 insertions(+), 28 deletions(-) (limited to 'OpenSim/Region/Environment') diff --git a/OpenSim/Region/Environment/Modules/Scripting/HttpRequest/ScriptsHttpRequests.cs b/OpenSim/Region/Environment/Modules/Scripting/HttpRequest/ScriptsHttpRequests.cs index 821c60e..faa6f3c 100644 --- a/OpenSim/Region/Environment/Modules/Scripting/HttpRequest/ScriptsHttpRequests.cs +++ b/OpenSim/Region/Environment/Modules/Scripting/HttpRequest/ScriptsHttpRequests.cs @@ -90,8 +90,8 @@ namespace OpenSim.Region.Environment.Modules.Scripting.HttpRequest private int httpTimeout = 30000; private string m_name = "HttpScriptRequests"; - private string m_proxyurl = ""; - private string m_proxyexcepts = ""; + private string m_proxyurl = ""; + private string m_proxyexcepts = ""; // private Dictionary m_pendingRequests; @@ -155,8 +155,8 @@ namespace OpenSim.Region.Environment.Modules.Scripting.HttpRequest htc.HttpTimeout = httpTimeout; htc.OutboundBody = body; htc.ResponseHeaders = headers; - htc.proxyurl = m_proxyurl; - htc.proxyexcepts = m_proxyexcepts; + htc.proxyurl = m_proxyurl; + htc.proxyexcepts = m_proxyexcepts; lock (HttpListLock) { @@ -344,21 +344,26 @@ namespace OpenSim.Region.Environment.Modules.Scripting.HttpRequest Request = (HttpWebRequest) WebRequest.Create(Url); Request.Method = HttpMethod; Request.ContentType = HttpMIMEType; - if (proxyurl.Length > 0) - { - if (proxyexcepts.Length > 0) { - string[] elist = proxyexcepts.Split(';'); - Request.Proxy = new WebProxy(proxyurl,true,elist); - } else { - Request.Proxy = new WebProxy(proxyurl,true); - } - } + + if (proxyurl != null && proxyurl.Length > 0) + { + if (proxyexcepts != null && proxyexcepts.Length > 0) + { + string[] elist = proxyexcepts.Split(';'); + Request.Proxy = new WebProxy(proxyurl, true, elist); + } + else + { + Request.Proxy = new WebProxy(proxyurl, true); + } + } foreach (KeyValuePair entry in ResponseHeaders) Request.Headers[entry.Key] = entry.Value; // Encode outbound data - if (OutboundBody.Length > 0) { + if (OutboundBody.Length > 0) + { byte[] data = Encoding.UTF8.GetBytes(OutboundBody); Request.ContentLength = data.Length; diff --git a/OpenSim/Region/Environment/Modules/Scripting/LoadImageURL/LoadImageURLModule.cs b/OpenSim/Region/Environment/Modules/Scripting/LoadImageURL/LoadImageURLModule.cs index af78c36..0112ee6 100644 --- a/OpenSim/Region/Environment/Modules/Scripting/LoadImageURL/LoadImageURLModule.cs +++ b/OpenSim/Region/Environment/Modules/Scripting/LoadImageURL/LoadImageURLModule.cs @@ -43,9 +43,8 @@ namespace OpenSim.Region.Environment.Modules.Scripting.LoadImageURL private Scene m_scene; private IDynamicTextureManager m_textureManager; - private string m_proxyurl = ""; - private string m_proxyexcepts = ""; - + private string m_proxyurl = ""; + private string m_proxyexcepts = ""; #region IDynamicTextureRender Members @@ -95,8 +94,9 @@ namespace OpenSim.Region.Environment.Modules.Scripting.LoadImageURL { m_scene = scene; } - m_proxyurl = config.Configs["Startup"].GetString("HttpProxy"); - m_proxyexcepts = config.Configs["Startup"].GetString("HttpProxyExceptions"); + + m_proxyurl = config.Configs["Startup"].GetString("HttpProxy"); + m_proxyexcepts = config.Configs["Startup"].GetString("HttpProxyExceptions"); } public void PostInitialise() @@ -127,15 +127,19 @@ namespace OpenSim.Region.Environment.Modules.Scripting.LoadImageURL private void MakeHttpRequest(string url, UUID requestID) { WebRequest request = HttpWebRequest.Create(url); - if (m_proxyurl.Length > 0) - { - if (m_proxyexcepts.Length > 0) { - string[] elist = m_proxyexcepts.Split(';'); - request.Proxy = new WebProxy(m_proxyurl,true,elist); - } else { - request.Proxy = new WebProxy(m_proxyurl,true); - } - } + + if (m_proxyurl != null && m_proxyurl.Length > 0) + { + if (m_proxyexcepts != null && m_proxyexcepts.Length > 0) + { + string[] elist = m_proxyexcepts.Split(';'); + request.Proxy = new WebProxy(m_proxyurl, true, elist); + } + else + { + request.Proxy = new WebProxy(m_proxyurl, true); + } + } RequestState state = new RequestState((HttpWebRequest) request, requestID); // IAsyncResult result = request.BeginGetResponse(new AsyncCallback(HttpRequestReturn), state); -- cgit v1.1