From cbc9ae898c474295567532c668644d09b698d59b Mon Sep 17 00:00:00 2001
From: Kevin Cozens
Date: Wed, 27 Mar 2013 17:26:17 -0400
Subject: Added missing functionality (mainly custom headers) to llHTTPRequest.
---
.../Shared/Api/Implementation/LSL_Api.cs | 169 +++++++++++++++------
.../Shared/Api/Runtime/LSL_Constants.cs | 15 +-
2 files changed, 128 insertions(+), 56 deletions(-)
(limited to 'OpenSim/Region/ScriptEngine/Shared')
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index bf84b16..969243c 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -67,6 +67,7 @@ using LSL_Rotation = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion;
using LSL_String = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString;
using LSL_Vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3;
using System.Reflection;
+using System.Linq;
using PermissionMask = OpenSim.Framework.PermissionMask;
namespace OpenSim.Region.ScriptEngine.Shared.Api
@@ -92,8 +93,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
///
/// Used for script sleeps when we are using co-operative script termination.
///
- /// null if co-operative script termination is not active
- WaitHandle m_coopSleepHandle;
+ /// null if co-operative script termination is not active
+ WaitHandle m_coopSleepHandle;
///
/// The item that hosts this script
@@ -119,6 +120,23 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
protected int EMAIL_PAUSE_TIME = 20; // documented delay value for smtp.
protected ISoundModule m_SoundModule = null;
+ //An array of HTTP/1.1 headers that are not allowed to be used
+ //as custom headers by llHTTPRequest.
+ private string[] HttpStandardHeaders =
+ {
+ "Accept", "Accept-Charset", "Accept-Encoding", "Accept-Language",
+ "Accept-Ranges", "Age", "Allow", "Authorization", "Cache-Control",
+ "Connection", "Content-Encoding", "Content-Language",
+ "Content-Length", "Content-Location", "Content-MD5",
+ "Content-Range", "Content-Type", "Date", "ETag", "Expect",
+ "Expires", "From", "Host", "If-Match", "If-Modified-Since",
+ "If-None-Match", "If-Range", "If-Unmodified-Since", "Last-Modified",
+ "Location", "Max-Forwards", "Pragma", "Proxy-Authenticate",
+ "Proxy-Authorization", "Range", "Referer", "Retry-After", "Server",
+ "TE", "Trailer", "Transfer-Encoding", "Upgrade", "User-Agent",
+ "Vary", "Via", "Warning", "WWW-Authenticate"
+ };
+
public void Initialize(
IScriptEngine scriptEngine, SceneObjectPart host, TaskInventoryItem item, WaitHandle coopSleepHandle)
{
@@ -303,7 +321,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
/// If the linkset has more than one entity and a linknum greater than zero but equal to or less than the number
/// of entities, then the entity which corresponds to that linknum is returned.
/// Otherwise, if a positive linknum is given which is greater than the number of entities in the linkset, then
- /// null is returned.
+ /// null is returned.
///
public ISceneEntity GetLinkEntity(int linknum)
{
@@ -1557,7 +1575,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (tex.FaceTextures[i] != null)
{
tex.FaceTextures[i].Shiny = sval;
- tex.FaceTextures[i].Bump = bump;;
+ tex.FaceTextures[i].Bump = bump;
}
tex.DefaultTexture.Shiny = sval;
tex.DefaultTexture.Bump = bump;
@@ -1666,7 +1684,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
texcolor.A = Util.Clip((float)alpha, 0.0f, 1.0f);
tex.DefaultTexture.RGBA = texcolor;
}
-
+
part.UpdateTextureEntry(tex.GetBytes());
return;
}
@@ -1787,7 +1805,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
rgb.x = texcolor.R;
rgb.y = texcolor.G;
rgb.z = texcolor.B;
-
+
return rgb;
}
else
@@ -1819,12 +1837,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{
UUID textureID = new UUID();
- textureID = ScriptUtils.GetAssetIdFromItemName(m_host, texture, (int)AssetType.Texture);
- if (textureID == UUID.Zero)
- {
- if (!UUID.TryParse(texture, out textureID))
- return;
- }
+ textureID = ScriptUtils.GetAssetIdFromItemName(m_host, texture, (int)AssetType.Texture);
+ if (textureID == UUID.Zero)
+ {
+ if (!UUID.TryParse(texture, out textureID))
+ return;
+ }
Primitive.TextureEntry tex = part.Shape.Textures;
@@ -2021,7 +2039,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
// IF YOU GET REGION CROSSINGS WORKING WITH THIS FUNCTION, REPLACE THE WORKAROUND.
//
// This workaround is to prevent silent failure of this function.
- // According to the specification on the SL Wiki, providing a position outside of the
+ // According to the specification on the SL Wiki, providing a position outside of the
if (pos.x < 0 || pos.x > Constants.RegionSize || pos.y < 0 || pos.y > Constants.RegionSize)
{
return 0;
@@ -2230,7 +2248,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{
return llGetRootRotation();
}
-
+
m_host.AddScriptLPS(1);
Quaternion q = m_host.GetWorldRotation();
return new LSL_Rotation(q.X, q.Y, q.Z, q.W);
@@ -2919,7 +2937,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
// we need to convert from a vector describing
// the angles of rotation in radians into rotation value
LSL_Rotation rot = llEuler2Rot(angle);
-
+
// Per discussion with Melanie, for non-physical objects llLookAt appears to simply
// set the rotation of the object, copy that behavior
PhysicsActor pa = m_host.PhysActor;
@@ -2996,7 +3014,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (!UUID.TryParse(id, out objectID))
objectID = UUID.Zero;
-
+
if (objectID == UUID.Zero && name == "")
return;
@@ -3182,19 +3200,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
msg.RegionID = World.RegionInfo.RegionID.Guid;//RegionID.Guid;
Vector3 pos = m_host.AbsolutePosition;
- msg.binaryBucket
+ msg.binaryBucket
= Util.StringToBytes256(
- "{0}/{1}/{2}/{3}",
- World.RegionInfo.RegionName,
- (int)Math.Floor(pos.X),
- (int)Math.Floor(pos.Y),
+ "{0}/{1}/{2}/{3}",
+ World.RegionInfo.RegionName,
+ (int)Math.Floor(pos.X),
+ (int)Math.Floor(pos.Y),
(int)Math.Floor(pos.Z));
if (m_TransferModule != null)
{
m_TransferModule.SendInstantMessage(msg, delegate(bool success) {});
}
-
+
ScriptSleep(2000);
}
@@ -3319,7 +3337,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
public void llRotLookAt(LSL_Rotation target, double strength, double damping)
{
m_host.AddScriptLPS(1);
-
+
// Per discussion with Melanie, for non-physical objects llLookAt appears to simply
// set the rotation of the object, copy that behavior
PhysicsActor pa = m_host.PhysActor;
@@ -4313,7 +4331,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
public void llCollisionSound(string impact_sound, double impact_volume)
{
m_host.AddScriptLPS(1);
-
+
// TODO: Parameter check logic required.
m_host.CollisionSound = ScriptUtils.GetAssetIdFromKeyOrItemName(m_host, impact_sound, AssetType.Sound);
m_host.CollisionSoundVolume = (float)impact_volume;
@@ -5008,7 +5026,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
// SL spits out an empty string for types other than key & string
// At the time of patching, LSL_Key is currently LSL_String,
// so the OR check may be a little redundant, but it's being done
- // for completion and should LSL_Key ever be implemented
+ // for completion and should LSL_Key ever be implemented
// as it's own struct
else if (!(src.Data[index] is LSL_String ||
src.Data[index] is LSL_Key))
@@ -5144,8 +5162,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{
m_host.AddScriptLPS(1);
- return string.Join(", ",
- (new List