Merge branch 'master' of ssh://opensimulator.org/var/git/opensim

integration
Justin Clark-Casey (justincc) 2012-08-29 23:16:16 +01:00
commit 1f88179a65
5 changed files with 49 additions and 2 deletions

View File

@ -84,6 +84,7 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
public string body; public string body;
public int responseCode; public int responseCode;
public string responseBody; public string responseBody;
public string responseType = "text/plain";
//public ManualResetEvent ev; //public ManualResetEvent ev;
public bool requestDone; public bool requestDone;
public int startTime; 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) public void HttpResponse(UUID request, int status, string body)
{ {
lock (m_UrlMap) lock (m_UrlMap)
@ -504,7 +521,8 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
//put response //put response
response["int_response_code"] = requestData.responseCode; response["int_response_code"] = requestData.responseCode;
response["str_response_string"] = requestData.responseBody; 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["keepalive"] = false;
response["reusecontext"] = false; response["reusecontext"] = false;

View File

@ -39,6 +39,8 @@ namespace OpenSim.Region.Framework.Interfaces
UUID RequestSecureURL(IScriptModule engine, SceneObjectPart host, UUID itemID); UUID RequestSecureURL(IScriptModule engine, SceneObjectPart host, UUID itemID);
void ReleaseURL(string url); void ReleaseURL(string url);
void HttpResponse(UUID request, int status, string body); void HttpResponse(UUID request, int status, string body);
void HttpContentType(UUID request, string type);
string GetHttpHeader(UUID request, string header); string GetHttpHeader(UUID request, string header);
int GetFreeUrls(); int GetFreeUrls();

View File

@ -140,12 +140,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
internal float m_ScriptDistanceFactor = 1.0f; internal float m_ScriptDistanceFactor = 1.0f;
internal Dictionary<string, FunctionPerms > m_FunctionPerms = new Dictionary<string, FunctionPerms >(); internal Dictionary<string, FunctionPerms > m_FunctionPerms = new Dictionary<string, FunctionPerms >();
protected IUrlModule m_UrlModule = null;
public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, TaskInventoryItem item) public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, TaskInventoryItem item)
{ {
m_ScriptEngine = ScriptEngine; m_ScriptEngine = ScriptEngine;
m_host = host; m_host = host;
m_item = item; m_item = item;
m_UrlModule = m_ScriptEngine.World.RequestModuleInterface<IUrlModule>();
if (m_ScriptEngine.Config.GetBoolean("AllowOSFunctions", false)) if (m_ScriptEngine.Config.GetBoolean("AllowOSFunctions", false))
m_OSFunctionsEnabled = true; m_OSFunctionsEnabled = true;
@ -3358,5 +3362,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
return new LSL_Key(m_host.ParentGroup.FromPartID.ToString()); 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);
}
} }
} }

View File

@ -365,5 +365,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
/// </summary> /// </summary>
/// <returns>Rezzing object key or NULL_KEY if rezzed by agent or otherwise unknown.</returns> /// <returns>Rezzing object key or NULL_KEY if rezzed by agent or otherwise unknown.</returns>
LSL_Key osGetRezzingObject(); LSL_Key osGetRezzingObject();
/// <summary>
/// Sets the response type for an HTTP request/response
/// </summary>
/// <returns></returns>
void osSetContentType(LSL_Key id, string type);
} }
} }

View File

@ -955,5 +955,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
{ {
return m_OSSL_Functions.osGetRezzingObject(); return m_OSSL_Functions.osGetRezzingObject();
} }
public void osSetContentType(LSL_Key id, string type)
{
m_OSSL_Functions.osSetContentType(id,type);
}
} }
} }