Added missing functionality (mainly custom headers) to llHTTPRequest.
parent
023faa227e
commit
cbc9ae898c
|
@ -187,6 +187,45 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest
|
||||||
case (int)HttpRequestConstants.HTTP_VERIFY_CERT:
|
case (int)HttpRequestConstants.HTTP_VERIFY_CERT:
|
||||||
htc.HttpVerifyCert = (int.Parse(parms[i + 1]) != 0);
|
htc.HttpVerifyCert = (int.Parse(parms[i + 1]) != 0);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case (int)HttpRequestConstants.HTTP_VERBOSE_THROTTLE:
|
||||||
|
|
||||||
|
// TODO implement me
|
||||||
|
break;
|
||||||
|
|
||||||
|
case (int)HttpRequestConstants.HTTP_CUSTOM_HEADER:
|
||||||
|
//Parameters are in pairs and custom header takes
|
||||||
|
//arguments in pairs so adjust for header marker.
|
||||||
|
++i;
|
||||||
|
|
||||||
|
//Maximum of 8 headers are allowed based on the
|
||||||
|
//Second Life documentation for llHTTPRequest.
|
||||||
|
for (int count = 1; count <= 8; ++count)
|
||||||
|
{
|
||||||
|
//Not enough parameters remaining for a header?
|
||||||
|
if (parms.Length - i < 2)
|
||||||
|
break;
|
||||||
|
|
||||||
|
//Have we reached the end of the list of headers?
|
||||||
|
//End is marked by a string with a single digit.
|
||||||
|
//We already know we have at least one parameter
|
||||||
|
//so it is safe to do this check at top of loop.
|
||||||
|
if (Char.IsDigit(parms[i][0]))
|
||||||
|
break;
|
||||||
|
|
||||||
|
if (htc.HttpCustomHeaders == null)
|
||||||
|
htc.HttpCustomHeaders = new List<string>();
|
||||||
|
|
||||||
|
htc.HttpCustomHeaders.Add(parms[i]);
|
||||||
|
htc.HttpCustomHeaders.Add(parms[i+1]);
|
||||||
|
|
||||||
|
i += 2;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case (int)HttpRequestConstants.HTTP_PRAGMA_NO_CACHE:
|
||||||
|
htc.HttpPragmaNoCache = (int.Parse(parms[i + 1]) != 0);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -328,6 +367,9 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest
|
||||||
// public const int HTTP_METHOD = 0;
|
// public const int HTTP_METHOD = 0;
|
||||||
// public const int HTTP_MIMETYPE = 1;
|
// public const int HTTP_MIMETYPE = 1;
|
||||||
// public const int HTTP_VERIFY_CERT = 3;
|
// public const int HTTP_VERIFY_CERT = 3;
|
||||||
|
// public const int HTTP_VERBOSE_THROTTLE = 4;
|
||||||
|
// public const int HTTP_CUSTOM_HEADER = 5;
|
||||||
|
// public const int HTTP_PRAGMA_NO_CACHE = 6;
|
||||||
private bool _finished;
|
private bool _finished;
|
||||||
public bool Finished
|
public bool Finished
|
||||||
{
|
{
|
||||||
|
@ -340,6 +382,9 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest
|
||||||
public string HttpMIMEType = "text/plain;charset=utf-8";
|
public string HttpMIMEType = "text/plain;charset=utf-8";
|
||||||
public int HttpTimeout;
|
public int HttpTimeout;
|
||||||
public bool HttpVerifyCert = true;
|
public bool HttpVerifyCert = true;
|
||||||
|
//public bool HttpVerboseThrottle = true; // not implemented
|
||||||
|
public List<string> HttpCustomHeaders = null;
|
||||||
|
public bool HttpPragmaNoCache = true;
|
||||||
private Thread httpThread;
|
private Thread httpThread;
|
||||||
|
|
||||||
// Request info
|
// Request info
|
||||||
|
@ -401,7 +446,7 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest
|
||||||
Request.Method = HttpMethod;
|
Request.Method = HttpMethod;
|
||||||
Request.ContentType = HttpMIMEType;
|
Request.ContentType = HttpMIMEType;
|
||||||
|
|
||||||
if(!HttpVerifyCert)
|
if (!HttpVerifyCert)
|
||||||
{
|
{
|
||||||
// We could hijack Connection Group Name to identify
|
// We could hijack Connection Group Name to identify
|
||||||
// a desired security exception. But at the moment we'll use a dummy header instead.
|
// a desired security exception. But at the moment we'll use a dummy header instead.
|
||||||
|
@ -412,6 +457,16 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest
|
||||||
// {
|
// {
|
||||||
// Request.ConnectionGroupName="Verify";
|
// Request.ConnectionGroupName="Verify";
|
||||||
// }
|
// }
|
||||||
|
if (!HttpPragmaNoCache)
|
||||||
|
{
|
||||||
|
Request.Headers.Add("Pragma", "no-cache");
|
||||||
|
}
|
||||||
|
if (HttpCustomHeaders != null)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < HttpCustomHeaders.Count; i += 2)
|
||||||
|
Request.Headers.Add(HttpCustomHeaders[i],
|
||||||
|
HttpCustomHeaders[i+1]);
|
||||||
|
}
|
||||||
if (proxyurl != null && proxyurl.Length > 0)
|
if (proxyurl != null && proxyurl.Length > 0)
|
||||||
{
|
{
|
||||||
if (proxyexcepts != null && proxyexcepts.Length > 0)
|
if (proxyexcepts != null && proxyexcepts.Length > 0)
|
||||||
|
|
|
@ -36,6 +36,9 @@ namespace OpenSim.Region.Framework.Interfaces
|
||||||
HTTP_MIMETYPE = 1,
|
HTTP_MIMETYPE = 1,
|
||||||
HTTP_BODY_MAXLENGTH = 2,
|
HTTP_BODY_MAXLENGTH = 2,
|
||||||
HTTP_VERIFY_CERT = 3,
|
HTTP_VERIFY_CERT = 3,
|
||||||
|
HTTP_VERBOSE_THROTTLE = 4,
|
||||||
|
HTTP_CUSTOM_HEADER = 5,
|
||||||
|
HTTP_PRAGMA_NO_CACHE = 6
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface IHttpRequestModule
|
public interface IHttpRequestModule
|
||||||
|
|
|
@ -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_String = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString;
|
||||||
using LSL_Vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3;
|
using LSL_Vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
using System.Linq;
|
||||||
using PermissionMask = OpenSim.Framework.PermissionMask;
|
using PermissionMask = OpenSim.Framework.PermissionMask;
|
||||||
|
|
||||||
namespace OpenSim.Region.ScriptEngine.Shared.Api
|
namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||||
|
@ -119,6 +120,23 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||||
protected int EMAIL_PAUSE_TIME = 20; // documented delay value for smtp.
|
protected int EMAIL_PAUSE_TIME = 20; // documented delay value for smtp.
|
||||||
protected ISoundModule m_SoundModule = null;
|
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(
|
public void Initialize(
|
||||||
IScriptEngine scriptEngine, SceneObjectPart host, TaskInventoryItem item, WaitHandle coopSleepHandle)
|
IScriptEngine scriptEngine, SceneObjectPart host, TaskInventoryItem item, WaitHandle coopSleepHandle)
|
||||||
{
|
{
|
||||||
|
@ -1557,7 +1575,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||||
if (tex.FaceTextures[i] != null)
|
if (tex.FaceTextures[i] != null)
|
||||||
{
|
{
|
||||||
tex.FaceTextures[i].Shiny = sval;
|
tex.FaceTextures[i].Shiny = sval;
|
||||||
tex.FaceTextures[i].Bump = bump;;
|
tex.FaceTextures[i].Bump = bump;
|
||||||
}
|
}
|
||||||
tex.DefaultTexture.Shiny = sval;
|
tex.DefaultTexture.Shiny = sval;
|
||||||
tex.DefaultTexture.Bump = bump;
|
tex.DefaultTexture.Bump = bump;
|
||||||
|
@ -10415,9 +10433,60 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||||
IHttpRequestModule httpScriptMod =
|
IHttpRequestModule httpScriptMod =
|
||||||
m_ScriptEngine.World.RequestModuleInterface<IHttpRequestModule>();
|
m_ScriptEngine.World.RequestModuleInterface<IHttpRequestModule>();
|
||||||
List<string> param = new List<string>();
|
List<string> param = new List<string>();
|
||||||
foreach (object o in parameters.Data)
|
bool ok;
|
||||||
|
Int32 flag;
|
||||||
|
|
||||||
|
for (int i = 0; i < parameters.Data.Length; i += 2)
|
||||||
{
|
{
|
||||||
param.Add(o.ToString());
|
ok = Int32.TryParse(parameters.Data[i].ToString(), out flag);
|
||||||
|
if (!ok || flag < 0 ||
|
||||||
|
flag > (int)HttpRequestConstants.HTTP_PRAGMA_NO_CACHE)
|
||||||
|
{
|
||||||
|
throw new ScriptException("Parameter " + i.ToString() + " is an invalid flag");
|
||||||
|
}
|
||||||
|
|
||||||
|
param.Add(parameters.Data[i].ToString()); //Add parameter flag
|
||||||
|
|
||||||
|
if (flag != (int)HttpRequestConstants.HTTP_CUSTOM_HEADER)
|
||||||
|
{
|
||||||
|
param.Add(parameters.Data[i+1].ToString()); //Add parameter value
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//Parameters are in pairs and custom header takes
|
||||||
|
//arguments in pairs so adjust for header marker.
|
||||||
|
++i;
|
||||||
|
|
||||||
|
//Maximum of 8 headers are allowed based on the
|
||||||
|
//Second Life documentation for llHTTPRequest.
|
||||||
|
for (int count = 1; count <= 8; ++count)
|
||||||
|
{
|
||||||
|
//Enough parameters remaining for (another) header?
|
||||||
|
if (parameters.Data.Length - i < 2)
|
||||||
|
{
|
||||||
|
//There must be at least one name/value pair for custom header
|
||||||
|
if (count == 1)
|
||||||
|
throw new ScriptException("Missing name/value for custom header at parameter " + i.ToString());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (HttpStandardHeaders.Contains(parameters.Data[i].ToString(), StringComparer.OrdinalIgnoreCase))
|
||||||
|
throw new ScriptException("Name is invalid as a custom header at parameter " + i.ToString());
|
||||||
|
|
||||||
|
param.Add(parameters.Data[i].ToString());
|
||||||
|
param.Add(parameters.Data[i+1].ToString());
|
||||||
|
|
||||||
|
//Have we reached the end of the list of headers?
|
||||||
|
//End is marked by a string with a single digit.
|
||||||
|
if (i+2 >= parameters.Data.Length ||
|
||||||
|
Char.IsDigit(parameters.Data[i].ToString()[0]))
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
i += 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector3 position = m_host.AbsolutePosition;
|
Vector3 position = m_host.AbsolutePosition;
|
||||||
|
|
|
@ -355,6 +355,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
|
||||||
public const int HTTP_MIMETYPE = 1;
|
public const int HTTP_MIMETYPE = 1;
|
||||||
public const int HTTP_BODY_MAXLENGTH = 2;
|
public const int HTTP_BODY_MAXLENGTH = 2;
|
||||||
public const int HTTP_VERIFY_CERT = 3;
|
public const int HTTP_VERIFY_CERT = 3;
|
||||||
|
public const int HTTP_VERBOSE_THROTTLE = 4;
|
||||||
|
public const int HTTP_CUSTOM_HEADER = 5;
|
||||||
|
public const int HTTP_PRAGMA_NO_CACHE = 6;
|
||||||
|
|
||||||
public const int PRIM_MATERIAL = 2;
|
public const int PRIM_MATERIAL = 2;
|
||||||
public const int PRIM_PHYSICS = 3;
|
public const int PRIM_PHYSICS = 3;
|
||||||
|
|
|
@ -2183,6 +2183,7 @@
|
||||||
|
|
||||||
<ReferencePath>../../../../../../bin/</ReferencePath>
|
<ReferencePath>../../../../../../bin/</ReferencePath>
|
||||||
<Reference name="System"/>
|
<Reference name="System"/>
|
||||||
|
<Reference name="System.Core"/>
|
||||||
<Reference name="System.Data"/>
|
<Reference name="System.Data"/>
|
||||||
<Reference name="System.Web"/>
|
<Reference name="System.Web"/>
|
||||||
<Reference name="System.Xml"/>
|
<Reference name="System.Xml"/>
|
||||||
|
|
Loading…
Reference in New Issue