This partially implements the LSL function to set the response
type for an HTTP request. Since the "official" LSL function limits the use of the response type, it is implemented as osSetContentType with a string for the content mime type and a threat level of high. With this function you should be able to implement rather functional media-on-a-prim application with much less difficulty.integration
parent
0c3061f973
commit
3d736d575f
|
@ -84,6 +84,7 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
|
|||
public string body;
|
||||
public int responseCode;
|
||||
public string responseBody;
|
||||
public string responseType = "text/plain";
|
||||
//public ManualResetEvent ev;
|
||||
public bool requestDone;
|
||||
public int startTime;
|
||||
|
@ -302,6 +303,22 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
|
|||
}
|
||||
}
|
||||
|
||||
public void HttpContentType(UUID request, string type)
|
||||
{
|
||||
lock (m_UrlMap)
|
||||
{
|
||||
if (m_RequestMap.ContainsKey(request))
|
||||
{
|
||||
UrlData urlData = m_RequestMap[request];
|
||||
urlData.requests[request].responseType = type;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_log.Info("[HttpRequestHandler] There is no http-in request with id " + request.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void HttpResponse(UUID request, int status, string body)
|
||||
{
|
||||
lock (m_UrlMap)
|
||||
|
@ -504,7 +521,8 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
|
|||
//put response
|
||||
response["int_response_code"] = requestData.responseCode;
|
||||
response["str_response_string"] = requestData.responseBody;
|
||||
response["content_type"] = "text/plain";
|
||||
response["content_type"] = requestData.responseType;
|
||||
// response["content_type"] = "text/plain";
|
||||
response["keepalive"] = false;
|
||||
response["reusecontext"] = false;
|
||||
|
||||
|
|
|
@ -39,6 +39,8 @@ namespace OpenSim.Region.Framework.Interfaces
|
|||
UUID RequestSecureURL(IScriptModule engine, SceneObjectPart host, UUID itemID);
|
||||
void ReleaseURL(string url);
|
||||
void HttpResponse(UUID request, int status, string body);
|
||||
void HttpContentType(UUID request, string type);
|
||||
|
||||
string GetHttpHeader(UUID request, string header);
|
||||
int GetFreeUrls();
|
||||
|
||||
|
|
|
@ -140,12 +140,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
|||
internal float m_ScriptDistanceFactor = 1.0f;
|
||||
internal Dictionary<string, FunctionPerms > m_FunctionPerms = new Dictionary<string, FunctionPerms >();
|
||||
|
||||
protected IUrlModule m_UrlModule = null;
|
||||
|
||||
public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, TaskInventoryItem item)
|
||||
{
|
||||
m_ScriptEngine = ScriptEngine;
|
||||
m_host = host;
|
||||
m_item = item;
|
||||
|
||||
m_UrlModule = m_ScriptEngine.World.RequestModuleInterface<IUrlModule>();
|
||||
|
||||
if (m_ScriptEngine.Config.GetBoolean("AllowOSFunctions", false))
|
||||
m_OSFunctionsEnabled = true;
|
||||
|
||||
|
@ -3358,5 +3362,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
|||
|
||||
return new LSL_Key(m_host.ParentGroup.FromPartID.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the response type for an HTTP request/response
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public void osSetContentType(LSL_Key id, string type)
|
||||
{
|
||||
CheckThreatLevel(ThreatLevel.High,"osSetResponseType");
|
||||
if (m_UrlModule != null)
|
||||
m_UrlModule.HttpContentType(new UUID(id),type);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -365,5 +365,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
|
|||
/// </summary>
|
||||
/// <returns>Rezzing object key or NULL_KEY if rezzed by agent or otherwise unknown.</returns>
|
||||
LSL_Key osGetRezzingObject();
|
||||
|
||||
/// <summary>
|
||||
/// Sets the response type for an HTTP request/response
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
void osSetContentType(LSL_Key id, string type);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -955,5 +955,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
|
|||
{
|
||||
return m_OSSL_Functions.osGetRezzingObject();
|
||||
}
|
||||
|
||||
public void osSetContentType(LSL_Key id, string type)
|
||||
{
|
||||
m_OSSL_Functions.osSetContentType(id,type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue