From 28820e618502beac65f246e00509d845dbdfe5ba Mon Sep 17 00:00:00 2001 From: Dahlia Trimble Date: Fri, 6 Feb 2009 01:25:59 +0000 Subject: Thanks cmickyb for a patch (Mantis#3089) that adds support for proxy in http requests --- .../Scripting/HttpRequest/ScriptsHttpRequests.cs | 19 +++++++++++++++++++ .../Scripting/LoadImageURL/LoadImageURLModule.cs | 16 ++++++++++++++++ bin/OpenSim.ini.example | 4 ++++ 3 files changed, 39 insertions(+) diff --git a/OpenSim/Region/Environment/Modules/Scripting/HttpRequest/ScriptsHttpRequests.cs b/OpenSim/Region/Environment/Modules/Scripting/HttpRequest/ScriptsHttpRequests.cs index 7b21832..eb9b322 100644 --- a/OpenSim/Region/Environment/Modules/Scripting/HttpRequest/ScriptsHttpRequests.cs +++ b/OpenSim/Region/Environment/Modules/Scripting/HttpRequest/ScriptsHttpRequests.cs @@ -90,6 +90,9 @@ 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 Dictionary m_pendingRequests; private Scene m_scene; @@ -152,6 +155,8 @@ namespace OpenSim.Region.Environment.Modules.Scripting.HttpRequest htc.httpTimeout = httpTimeout; htc.outbound_body = body; htc.response_headers = headers; + htc.proxyurl = m_proxyurl; + htc.proxyexcepts = m_proxyexcepts; lock (HttpListLock) { @@ -232,6 +237,9 @@ namespace OpenSim.Region.Environment.Modules.Scripting.HttpRequest m_scene.RegisterModuleInterface(this); + m_proxyurl = config.Configs["Startup"].GetString("HttpProxy"); + m_proxyexcepts = config.Configs["Startup"].GetString("HttpProxyExceptions"); + m_pendingRequests = new Dictionary(); } @@ -285,6 +293,8 @@ namespace OpenSim.Region.Environment.Modules.Scripting.HttpRequest public Dictionary response_headers; public int status; public string url; + public string proxyurl; + public string proxyexcepts; public void process() { @@ -316,6 +326,15 @@ namespace OpenSim.Region.Environment.Modules.Scripting.HttpRequest 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); + } + } foreach (KeyValuePair entry in response_headers) request.Headers[entry.Key] = entry.Value; diff --git a/OpenSim/Region/Environment/Modules/Scripting/LoadImageURL/LoadImageURLModule.cs b/OpenSim/Region/Environment/Modules/Scripting/LoadImageURL/LoadImageURLModule.cs index eeeb3ca..3d0afd1 100644 --- a/OpenSim/Region/Environment/Modules/Scripting/LoadImageURL/LoadImageURLModule.cs +++ b/OpenSim/Region/Environment/Modules/Scripting/LoadImageURL/LoadImageURLModule.cs @@ -43,6 +43,10 @@ namespace OpenSim.Region.Environment.Modules.Scripting.LoadImageURL private Scene m_scene; private IDynamicTextureManager m_textureManager; + private string m_proxyurl = ""; + private string m_proxyexcepts = ""; + + #region IDynamicTextureRender Members public string GetName() @@ -91,6 +95,8 @@ namespace OpenSim.Region.Environment.Modules.Scripting.LoadImageURL { m_scene = scene; } + m_proxyurl = config.Configs["Startup"].GetString("HttpProxy"); + m_proxyexcepts = config.Configs["Startup"].GetString("HttpProxyExceptions"); } public void PostInitialise() @@ -121,6 +127,16 @@ 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); + } + } + RequestState state = new RequestState((HttpWebRequest) request, requestID); // IAsyncResult result = request.BeginGetResponse(new AsyncCallback(HttpRequestReturn), state); request.BeginGetResponse(new AsyncCallback(HttpRequestReturn), state); diff --git a/bin/OpenSim.ini.example b/bin/OpenSim.ini.example index 481cbbf..e950c12 100644 --- a/bin/OpenSim.ini.example +++ b/bin/OpenSim.ini.example @@ -7,6 +7,10 @@ ; (eg default is /opensimdir/crashes/*.txt or C:\opensim\crashes\*.txt) crash_dir = "crashes" + ; Http proxy support for llHTTPRequest and dynamic texture loading + HttpProxy = "http://proxy.com" + HttpProxyExceptions = ".mydomain.com;localhost" + ; Set this to true if you are connecting your OpenSimulator regions to a grid ; Set this to false if you are running OpenSimulator in standalone mode gridmode = false -- cgit v1.1