diff options
author | Melanie | 2013-05-05 22:01:07 +0200 |
---|---|---|
committer | Melanie | 2013-05-05 22:01:07 +0200 |
commit | a8faed6f76e5bb7936c1bc2b4711b5eeb143173d (patch) | |
tree | e4d3502d5e56b66a6841f7aa6cf3e58ecda96222 | |
parent | Add RegionManager level and the ability to use literal XML to the dynamic flo... (diff) | |
download | opensim-SC-a8faed6f76e5bb7936c1bc2b4711b5eeb143173d.zip opensim-SC-a8faed6f76e5bb7936c1bc2b4711b5eeb143173d.tar.gz opensim-SC-a8faed6f76e5bb7936c1bc2b4711b5eeb143173d.tar.bz2 opensim-SC-a8faed6f76e5bb7936c1bc2b4711b5eeb143173d.tar.xz |
Implement llSetContentType using the new OpenID auth support for authentication
5 files changed, 71 insertions, 1 deletions
diff --git a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs index f2922d6..2a4d440 100644 --- a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs | |||
@@ -51,6 +51,7 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp | |||
51 | public UUID urlcode; | 51 | public UUID urlcode; |
52 | public Dictionary<UUID, RequestData> requests; | 52 | public Dictionary<UUID, RequestData> requests; |
53 | public bool isSsl; | 53 | public bool isSsl; |
54 | public Scene scene; | ||
54 | } | 55 | } |
55 | 56 | ||
56 | public class RequestData | 57 | public class RequestData |
@@ -66,6 +67,9 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp | |||
66 | public int startTime; | 67 | public int startTime; |
67 | public bool responseSent; | 68 | public bool responseSent; |
68 | public string uri; | 69 | public string uri; |
70 | public bool allowResponseType = false; | ||
71 | public UUID hostID; | ||
72 | public Scene scene; | ||
69 | } | 73 | } |
70 | 74 | ||
71 | /// <summary> | 75 | /// <summary> |
@@ -171,6 +175,17 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp | |||
171 | 175 | ||
172 | public void RemoveRegion(Scene scene) | 176 | public void RemoveRegion(Scene scene) |
173 | { | 177 | { |
178 | // Drop references to that scene | ||
179 | foreach (KeyValuePair<string, UrlData> kvp in m_UrlMap) | ||
180 | { | ||
181 | if (kvp.Value.scene == scene) | ||
182 | kvp.Value.scene = null; | ||
183 | } | ||
184 | foreach (KeyValuePair<UUID, UrlData> kvp in m_RequestMap) | ||
185 | { | ||
186 | if (kvp.Value.scene == scene) | ||
187 | kvp.Value.scene = null; | ||
188 | } | ||
174 | } | 189 | } |
175 | 190 | ||
176 | public void Close() | 191 | public void Close() |
@@ -198,6 +213,7 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp | |||
198 | urlData.urlcode = urlcode; | 213 | urlData.urlcode = urlcode; |
199 | urlData.isSsl = false; | 214 | urlData.isSsl = false; |
200 | urlData.requests = new Dictionary<UUID, RequestData>(); | 215 | urlData.requests = new Dictionary<UUID, RequestData>(); |
216 | urlData.scene = host.ParentGroup.Scene; | ||
201 | 217 | ||
202 | m_UrlMap[url] = urlData; | 218 | m_UrlMap[url] = urlData; |
203 | 219 | ||
@@ -316,6 +332,11 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp | |||
316 | if (!urlData.requests[request].responseSent) | 332 | if (!urlData.requests[request].responseSent) |
317 | { | 333 | { |
318 | string responseBody = body; | 334 | string responseBody = body; |
335 | |||
336 | // If we have no OpenID from built-in browser, disable this | ||
337 | if (!urlData.requests[request].allowResponseType) | ||
338 | urlData.requests[request].responseType = "text/plain"; | ||
339 | |||
319 | if (urlData.requests[request].responseType.Equals("text/plain")) | 340 | if (urlData.requests[request].responseType.Equals("text/plain")) |
320 | { | 341 | { |
321 | string value; | 342 | string value; |
@@ -532,7 +553,7 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp | |||
532 | //put response | 553 | //put response |
533 | response["int_response_code"] = requestData.responseCode; | 554 | response["int_response_code"] = requestData.responseCode; |
534 | response["str_response_string"] = requestData.responseBody; | 555 | response["str_response_string"] = requestData.responseBody; |
535 | response["content_type"] = "text/plain"; | 556 | response["content_type"] = requestData.responseType; |
536 | response["keepalive"] = false; | 557 | response["keepalive"] = false; |
537 | response["reusecontext"] = false; | 558 | response["reusecontext"] = false; |
538 | 559 | ||
@@ -600,6 +621,8 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp | |||
600 | requestData.requestDone = false; | 621 | requestData.requestDone = false; |
601 | requestData.startTime = System.Environment.TickCount; | 622 | requestData.startTime = System.Environment.TickCount; |
602 | requestData.uri = uri; | 623 | requestData.uri = uri; |
624 | requestData.hostID = url.hostID; | ||
625 | requestData.scene = url.scene; | ||
603 | if (requestData.headers == null) | 626 | if (requestData.headers == null) |
604 | requestData.headers = new Dictionary<string, string>(); | 627 | requestData.headers = new Dictionary<string, string>(); |
605 | 628 | ||
@@ -608,6 +631,32 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp | |||
608 | string key = (string)header.Key; | 631 | string key = (string)header.Key; |
609 | string value = (string)header.Value; | 632 | string value = (string)header.Value; |
610 | requestData.headers.Add(key, value); | 633 | requestData.headers.Add(key, value); |
634 | if (key == "cookie") | ||
635 | { | ||
636 | string[] parts = value.Split(new char[] {'='}); | ||
637 | if (parts[0] == "agni_sl_session_id" && parts.Length > 1) | ||
638 | { | ||
639 | string cookie = Uri.UnescapeDataString(parts[1]); | ||
640 | string[] crumbs = cookie.Split(new char[] {':'}); | ||
641 | UUID owner; | ||
642 | if (crumbs.Length == 2 && UUID.TryParse(crumbs[0], out owner)) | ||
643 | { | ||
644 | if (crumbs[1].Length == 32) | ||
645 | { | ||
646 | Scene scene = requestData.scene; | ||
647 | if (scene != null) | ||
648 | { | ||
649 | SceneObjectPart host = scene.GetSceneObjectPart(requestData.hostID); | ||
650 | if (host != null) | ||
651 | { | ||
652 | if (host.OwnerID == owner) | ||
653 | requestData.allowResponseType = true; | ||
654 | } | ||
655 | } | ||
656 | } | ||
657 | } | ||
658 | } | ||
659 | } | ||
611 | } | 660 | } |
612 | foreach (DictionaryEntry de in request) | 661 | foreach (DictionaryEntry de in request) |
613 | { | 662 | { |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index bb89ac1..6bcb361 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | |||
@@ -13386,6 +13386,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
13386 | 13386 | ||
13387 | return null; | 13387 | return null; |
13388 | } | 13388 | } |
13389 | |||
13390 | public void llSetContentType(LSL_Key id, LSL_Integer content_type) | ||
13391 | { | ||
13392 | if (m_UrlModule != null) | ||
13393 | { | ||
13394 | string type = "text.plain"; | ||
13395 | if (content_type == (int)ScriptBaseClass.CONTENT_TYPE_HTML) | ||
13396 | type = "text/html"; | ||
13397 | |||
13398 | m_UrlModule.HttpContentType(new UUID(id),type); | ||
13399 | } | ||
13400 | } | ||
13389 | } | 13401 | } |
13390 | 13402 | ||
13391 | public class NotecardCache | 13403 | public class NotecardCache |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs index bc8d321..daf89e5 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs | |||
@@ -434,5 +434,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces | |||
434 | void llSetKeyframedMotion(LSL_List frames, LSL_List options); | 434 | void llSetKeyframedMotion(LSL_List frames, LSL_List options); |
435 | LSL_List GetPrimitiveParamsEx(LSL_Key prim, LSL_List rules); | 435 | LSL_List GetPrimitiveParamsEx(LSL_Key prim, LSL_List rules); |
436 | LSL_List llGetPhysicsMaterial(); | 436 | LSL_List llGetPhysicsMaterial(); |
437 | void llSetContentType(LSL_Key id, LSL_Integer content_type); | ||
437 | } | 438 | } |
438 | } | 439 | } |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs index 2f8154d..c664a84 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs | |||
@@ -771,5 +771,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
771 | /// process message parameter as regex | 771 | /// process message parameter as regex |
772 | /// </summary> | 772 | /// </summary> |
773 | public const int OS_LISTEN_REGEX_MESSAGE = 0x2; | 773 | public const int OS_LISTEN_REGEX_MESSAGE = 0x2; |
774 | |||
775 | public const int CONTENT_TYPE_TEXT = 0; | ||
776 | public const int CONTENT_TYPE_HTML = 1; | ||
774 | } | 777 | } |
775 | } | 778 | } |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs index b6bb5d8..6f3677c 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs | |||
@@ -2014,5 +2014,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
2014 | { | 2014 | { |
2015 | return m_LSL_Functions.llGetPhysicsMaterial(); | 2015 | return m_LSL_Functions.llGetPhysicsMaterial(); |
2016 | } | 2016 | } |
2017 | |||
2018 | public void llSetContentType(LSL_Key id, LSL_Integer content_type) | ||
2019 | { | ||
2020 | m_LSL_Functions.llSetContentType(id, content_type); | ||
2021 | } | ||
2017 | } | 2022 | } |
2018 | } | 2023 | } |