Add regression test for llRequestUrl()
parent
e13f71048d
commit
28219d622f
|
@ -119,15 +119,11 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
|
|||
/// </summary>
|
||||
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
|
||||
{
|
||||
|
@ -141,11 +137,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 (ssl_enabled)
|
||||
https_port = (uint) config.Configs["Network"].GetInt("https_port",0);
|
||||
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 (ExternalHostNameForLSL == null)
|
||||
ExternalHostNameForLSL = System.Environment.MachineName;
|
||||
|
||||
IConfig llFunctionsConfig = config.Configs["LL-Functions"];
|
||||
|
||||
|
@ -166,9 +171,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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -206,7 +211,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;
|
||||
|
@ -251,7 +256,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;
|
||||
|
@ -545,9 +550,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.
|
||||
|
|
|
@ -52,7 +52,18 @@ namespace OpenSim.Region.Framework.Interfaces
|
|||
string GetXMLState(UUID itemID);
|
||||
bool SetXMLState(UUID itemID, string xml);
|
||||
|
||||
/// <summary>
|
||||
/// Post a script event to a single script.
|
||||
/// </summary>
|
||||
/// <returns>true if the post suceeded, false if it did not</returns>
|
||||
/// <param name='itemID'>The item ID of the script.</param>
|
||||
/// <param name='name'>The name of the event.</param>
|
||||
/// <param name='args'>
|
||||
/// The arguments of the event. These are in the order in which they appear.
|
||||
/// e.g. for http_request this will be an object array of key request_id, string method, string body
|
||||
/// </param>
|
||||
bool PostScriptEvent(UUID itemID, string name, Object[] args);
|
||||
|
||||
bool PostObjectEvent(UUID itemID, string name, Object[] args);
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -9317,6 +9317,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
|||
return UUID.Zero.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
public LSL_String llRequestURL()
|
||||
{
|
||||
m_host.AddScriptLPS(1);
|
||||
|
|
|
@ -40,10 +40,33 @@ namespace OpenSim.Tests.Common
|
|||
{
|
||||
public class MockScriptEngine : INonSharedRegionModule, IScriptModule, IScriptEngine
|
||||
{
|
||||
public IConfigSource ConfigSource { get; private set; }
|
||||
|
||||
public IConfig Config { get; private set; }
|
||||
|
||||
private Scene m_scene;
|
||||
|
||||
/// <summary>
|
||||
/// Expose posted events to tests.
|
||||
/// </summary>
|
||||
public Dictionary<UUID, List<EventParams>> PostedEvents { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// A very primitive way of hooking text cose to a posed event.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// May be replaced with something that uses more original code in the future.
|
||||
/// </remarks>
|
||||
public event Action<UUID, EventParams> PostEventHook;
|
||||
|
||||
public void Initialise(IConfigSource source)
|
||||
{
|
||||
ConfigSource = source;
|
||||
|
||||
// Can set later on if required
|
||||
Config = new IniConfig("MockScriptEngine", ConfigSource);
|
||||
|
||||
PostedEvents = new Dictionary<UUID, List<EventParams>>();
|
||||
}
|
||||
|
||||
public void Close()
|
||||
|
@ -85,7 +108,28 @@ namespace OpenSim.Tests.Common
|
|||
|
||||
public bool PostScriptEvent(UUID itemID, string name, object[] args)
|
||||
{
|
||||
return false;
|
||||
// Console.WriteLine("Posting event {0} for {1}", name, itemID);
|
||||
|
||||
EventParams evParams = new EventParams(name, args, null);
|
||||
|
||||
List<EventParams> eventsForItem;
|
||||
|
||||
if (!PostedEvents.ContainsKey(itemID))
|
||||
{
|
||||
eventsForItem = new List<EventParams>();
|
||||
PostedEvents.Add(itemID, eventsForItem);
|
||||
}
|
||||
else
|
||||
{
|
||||
eventsForItem = PostedEvents[itemID];
|
||||
}
|
||||
|
||||
eventsForItem.Add(evParams);
|
||||
|
||||
if (PostEventHook != null)
|
||||
PostEventHook(itemID, evParams);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool PostObjectEvent(UUID itemID, string name, object[] args)
|
||||
|
@ -195,11 +239,7 @@ namespace OpenSim.Tests.Common
|
|||
|
||||
public Scene World { get { return m_scene; } }
|
||||
|
||||
public IScriptModule ScriptModule { get { throw new System.NotImplementedException(); } }
|
||||
|
||||
public IConfig Config { get { throw new System.NotImplementedException (); } }
|
||||
|
||||
public IConfigSource ConfigSource { get { throw new System.NotImplementedException (); } }
|
||||
public IScriptModule ScriptModule { get { return this; } }
|
||||
|
||||
public string ScriptEnginePath { get { throw new System.NotImplementedException (); }}
|
||||
|
||||
|
@ -210,5 +250,10 @@ namespace OpenSim.Tests.Common
|
|||
public string[] ScriptReferencedAssemblies { get { throw new System.NotImplementedException (); } }
|
||||
|
||||
public ParameterInfo[] ScriptBaseClassParameters { get { throw new System.NotImplementedException (); } }
|
||||
|
||||
public void ClearPostedEvents()
|
||||
{
|
||||
PostedEvents.Clear();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -3276,6 +3276,8 @@
|
|||
<Reference name="System.Xml"/>
|
||||
<Reference name="OpenSim.Framework"/>
|
||||
<Reference name="OpenSim.Framework.Communications"/>
|
||||
<Reference name="OpenSim.Framework.Servers"/>
|
||||
<Reference name="OpenSim.Framework.Servers.HttpServer"/>
|
||||
<Reference name="OpenSim.Region.CoreModules"/>
|
||||
<Reference name="OpenSim.Region.Framework"/>
|
||||
<Reference name="OpenSim.Region.OptionalModules"/>
|
||||
|
|
Loading…
Reference in New Issue