From b8a7c8b26f3005eed5b161c37509b06b1d604967 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 26 Feb 2013 23:36:36 +0000 Subject: Add regression test for llRequestUrl() --- .../CoreModules/Scripting/LSLHttp/UrlModule.cs | 37 ++++++++++++---------- 1 file changed, 21 insertions(+), 16 deletions(-) (limited to 'OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs') diff --git a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs index be617a5..79e633f 100644 --- a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs @@ -122,15 +122,11 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp /// private int m_TotalUrls = 100; - private uint https_port = 0; + private uint m_HttpsPort = 0; private IHttpServer m_HttpServer = null; private IHttpServer m_HttpsServer = null; - private string m_ExternalHostNameForLSL = ""; - public string ExternalHostNameForLSL - { - get { return m_ExternalHostNameForLSL; } - } + public string ExternalHostNameForLSL { get; private set; } public Type ReplaceableInterface { @@ -144,11 +140,20 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp public void Initialise(IConfigSource config) { - m_ExternalHostNameForLSL = config.Configs["Network"].GetString("ExternalHostNameForLSL", System.Environment.MachineName); - bool ssl_enabled = config.Configs["Network"].GetBoolean("https_listener",false); + IConfig networkConfig = config.Configs["Network"]; + + if (networkConfig != null) + { + ExternalHostNameForLSL = config.Configs["Network"].GetString("ExternalHostNameForLSL", null); + + bool ssl_enabled = config.Configs["Network"].GetBoolean("https_listener", false); + + if (ssl_enabled) + m_HttpsPort = (uint)config.Configs["Network"].GetInt("https_port", (int)m_HttpsPort); + } - if (ssl_enabled) - https_port = (uint) config.Configs["Network"].GetInt("https_port",0); + if (ExternalHostNameForLSL == null) + ExternalHostNameForLSL = System.Environment.MachineName; IConfig llFunctionsConfig = config.Configs["LL-Functions"]; @@ -169,9 +174,9 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp m_HttpServer = MainServer.Instance; // // We can use the https if it is enabled - if (https_port > 0) + if (m_HttpsPort > 0) { - m_HttpsServer = MainServer.GetHttpServer(https_port); + m_HttpsServer = MainServer.GetHttpServer(m_HttpsPort); } } @@ -209,7 +214,7 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp engine.PostScriptEvent(itemID, "http_request", new Object[] { urlcode.ToString(), "URL_REQUEST_DENIED", "" }); return urlcode; } - string url = "http://" + m_ExternalHostNameForLSL + ":" + m_HttpServer.Port.ToString() + "/lslhttp/" + urlcode.ToString() + "/"; + string url = "http://" + ExternalHostNameForLSL + ":" + m_HttpServer.Port.ToString() + "/lslhttp/" + urlcode.ToString() + "/"; UrlData urlData = new UrlData(); urlData.hostID = host.UUID; @@ -254,7 +259,7 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp engine.PostScriptEvent(itemID, "http_request", new Object[] { urlcode.ToString(), "URL_REQUEST_DENIED", "" }); return urlcode; } - string url = "https://" + m_ExternalHostNameForLSL + ":" + m_HttpsServer.Port.ToString() + "/lslhttps/" + urlcode.ToString() + "/"; + string url = "https://" + ExternalHostNameForLSL + ":" + m_HttpsServer.Port.ToString() + "/lslhttps/" + urlcode.ToString() + "/"; UrlData urlData = new UrlData(); urlData.hostID = host.UUID; @@ -579,9 +584,9 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp string url; if (is_ssl) - url = "https://" + m_ExternalHostNameForLSL + ":" + m_HttpsServer.Port.ToString() + uri_tmp; + url = "https://" + ExternalHostNameForLSL + ":" + m_HttpsServer.Port.ToString() + uri_tmp; else - url = "http://" + m_ExternalHostNameForLSL + ":" + m_HttpServer.Port.ToString() + uri_tmp; + url = "http://" + ExternalHostNameForLSL + ":" + m_HttpServer.Port.ToString() + uri_tmp; // Avoid a race - the request URL may have been released via llRequestUrl() whilst this // request was being processed. -- cgit v1.1