mirror of
https://github.com/opensim/opensim.git
synced 2026-08-10 19:36:07 +08:00
Merge branch 'opensim:master' into master
This commit is contained in:
@@ -140,9 +140,7 @@ namespace OpenSim.Framework
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return "AnimID=" + AnimID.ToString()
|
||||
+ "/seq=" + SequenceNum.ToString()
|
||||
+ "/objID=" + ObjectID.ToString();
|
||||
return $"AnimID= {AnimID}/seq={SequenceNum}/objID={ObjectID}";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -257,7 +257,6 @@ namespace OpenSim.Framework.Monitoring
|
||||
m_log.DebugFormat("[{0}]: Processed job {1}",LoggingName,currentJob.Name);
|
||||
|
||||
currentJob.Action = null;
|
||||
currentJob = null;
|
||||
}
|
||||
lock (JobLock)
|
||||
--m_numberThreads;
|
||||
|
||||
@@ -27,23 +27,21 @@
|
||||
|
||||
using OpenMetaverse;
|
||||
using System;
|
||||
using System.Collections.Frozen;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace OpenSim.Framework
|
||||
{
|
||||
public static class SLUtil
|
||||
{
|
||||
// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
//private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
/// <summary>
|
||||
/// Asset types used only in OpenSim.
|
||||
/// To avoid clashing with the code numbers used in Second Life, use only negative numbers here.
|
||||
/// </summary>
|
||||
public enum OpenSimAssetType : sbyte
|
||||
{
|
||||
Material = -2
|
||||
}
|
||||
|
||||
#region SL / file extension / content-type conversions
|
||||
|
||||
@@ -55,81 +53,48 @@ namespace OpenSim.Framework
|
||||
{
|
||||
if (Enum.IsDefined(typeof(OpenMetaverse.AssetType), assetType))
|
||||
return (OpenMetaverse.AssetType)assetType;
|
||||
else if (Enum.IsDefined(typeof(OpenSimAssetType), assetType))
|
||||
return (OpenSimAssetType)assetType;
|
||||
else
|
||||
return OpenMetaverse.AssetType.Unknown;
|
||||
}
|
||||
|
||||
private class TypeMapping
|
||||
private struct TypeMapping
|
||||
{
|
||||
private sbyte assetType;
|
||||
private sbyte inventoryType;
|
||||
private string contentType;
|
||||
private string contentType2;
|
||||
private string extension;
|
||||
|
||||
public sbyte AssetTypeCode
|
||||
{
|
||||
get { return assetType; }
|
||||
}
|
||||
|
||||
public object AssetType
|
||||
{
|
||||
get { return AssetTypeFromCode(assetType); }
|
||||
}
|
||||
|
||||
public sbyte InventoryType
|
||||
{
|
||||
get { return inventoryType; }
|
||||
}
|
||||
|
||||
public string ContentType
|
||||
{
|
||||
get { return contentType; }
|
||||
}
|
||||
|
||||
public string ContentType2
|
||||
{
|
||||
get { return contentType2; }
|
||||
}
|
||||
|
||||
public string Extension
|
||||
{
|
||||
get { return extension; }
|
||||
}
|
||||
public readonly sbyte AssetType;
|
||||
public readonly sbyte InventoryType;
|
||||
public readonly string ContentType;
|
||||
public readonly string ContentType2;
|
||||
public readonly string Extension;
|
||||
|
||||
private TypeMapping(sbyte assetType, sbyte inventoryType, string contentType, string contentType2, string extension)
|
||||
{
|
||||
this.assetType = assetType;
|
||||
this.inventoryType = inventoryType;
|
||||
this.contentType = contentType;
|
||||
this.contentType2 = contentType2;
|
||||
this.extension = extension;
|
||||
AssetType = assetType;
|
||||
InventoryType = inventoryType;
|
||||
ContentType = contentType;
|
||||
ContentType2 = contentType2;
|
||||
Extension = extension;
|
||||
}
|
||||
|
||||
public TypeMapping(AssetType assetType, sbyte inventoryType, string contentType, string contentType2, string extension)
|
||||
: this((sbyte)assetType, inventoryType, contentType, contentType2, extension)
|
||||
{
|
||||
AssetType = (sbyte)assetType;
|
||||
InventoryType = inventoryType;
|
||||
ContentType = contentType;
|
||||
ContentType2 = contentType2;
|
||||
Extension = extension;
|
||||
}
|
||||
|
||||
public TypeMapping(AssetType assetType, InventoryType inventoryType, string contentType, string contentType2, string extension)
|
||||
: this((sbyte)assetType, (sbyte)inventoryType, contentType, contentType2, extension)
|
||||
: this(assetType, (sbyte)inventoryType, contentType, contentType2, extension)
|
||||
{
|
||||
}
|
||||
|
||||
public TypeMapping(AssetType assetType, InventoryType inventoryType, string contentType, string extension)
|
||||
: this((sbyte)assetType, (sbyte)inventoryType, contentType, null, extension)
|
||||
: this(assetType, (sbyte)inventoryType, contentType, null, extension)
|
||||
{
|
||||
}
|
||||
|
||||
public TypeMapping(AssetType assetType, FolderType inventoryType, string contentType, string extension)
|
||||
: this((sbyte)assetType, (sbyte)inventoryType, contentType, null, extension)
|
||||
{
|
||||
}
|
||||
|
||||
public TypeMapping(OpenSimAssetType assetType, InventoryType inventoryType, string contentType, string extension)
|
||||
: this((sbyte)assetType, (sbyte)inventoryType, contentType, null, extension)
|
||||
: this(assetType, (sbyte)inventoryType, contentType, null, extension)
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -140,7 +105,7 @@ namespace OpenSim.Framework
|
||||
/// AssetType "AssetType.Texture" -> Content-Type "image-xj2c"
|
||||
/// Content-Type "image/x-j2c" -> InventoryType "InventoryType.Texture"
|
||||
/// </summary>
|
||||
private static TypeMapping[] MAPPINGS = new TypeMapping[] {
|
||||
private static TypeMapping[] MAPPINGS = [
|
||||
new TypeMapping(AssetType.Unknown, InventoryType.Unknown, "application/octet-stream", "bin"),
|
||||
new TypeMapping(AssetType.Texture, InventoryType.Texture, "image/x-j2c", "image/jp2", "j2c"),
|
||||
new TypeMapping(AssetType.Texture, InventoryType.Snapshot, "image/x-j2c", "image/jp2", "j2c"),
|
||||
@@ -183,15 +148,15 @@ namespace OpenSim.Framework
|
||||
new TypeMapping(AssetType.Folder, InventoryType.Folder, "application/vnd.ll.folder", "folder"),
|
||||
|
||||
// OpenSim specific
|
||||
new TypeMapping(OpenSimAssetType.Material, InventoryType.Unknown, "application/llsd+xml", "material")
|
||||
};
|
||||
new TypeMapping(AssetType.OSMaterial, InventoryType.Unknown, "application/llsd+xml", "material")
|
||||
];
|
||||
|
||||
private static Dictionary<sbyte, string> asset2Content;
|
||||
private static Dictionary<sbyte, string> asset2Extension;
|
||||
private static Dictionary<sbyte, string> inventory2Content;
|
||||
private static Dictionary<string, sbyte> content2Asset;
|
||||
private static Dictionary<string, sbyte> content2Inventory;
|
||||
private static Dictionary<string, AssetType> name2Asset = new Dictionary<string, AssetType>()
|
||||
private static readonly FrozenDictionary<sbyte, string> asset2Content;
|
||||
private static readonly FrozenDictionary<sbyte, string> asset2Extension;
|
||||
private static readonly FrozenDictionary<sbyte, string> inventory2Content;
|
||||
private static readonly FrozenDictionary<string, sbyte> content2Asset;
|
||||
private static readonly FrozenDictionary<string, sbyte> content2Inventory;
|
||||
private static readonly FrozenDictionary<string, AssetType> name2Asset = new Dictionary<string, AssetType>()
|
||||
{
|
||||
{"texture", AssetType.Texture },
|
||||
{"sound", AssetType.Sound},
|
||||
@@ -215,8 +180,9 @@ namespace OpenSim.Framework
|
||||
{"mesh", AssetType.Mesh},
|
||||
{"settings", AssetType.Settings},
|
||||
{"material", AssetType.Material}
|
||||
};
|
||||
private static Dictionary<string, FolderType> name2Inventory = new Dictionary<string, FolderType>()
|
||||
}.ToFrozenDictionary();
|
||||
|
||||
private static readonly FrozenDictionary<string, FolderType> name2Inventory = new Dictionary<string, FolderType>()
|
||||
{
|
||||
{"texture", FolderType.Texture},
|
||||
{"sound", FolderType.Sound},
|
||||
@@ -242,108 +208,94 @@ namespace OpenSim.Framework
|
||||
{"settings", FolderType.Settings},
|
||||
{"material", FolderType.Material},
|
||||
{"suitcase", FolderType.Suitcase}
|
||||
};
|
||||
}.ToFrozenDictionary();
|
||||
|
||||
static SLUtil()
|
||||
{
|
||||
asset2Content = new Dictionary<sbyte, string>();
|
||||
asset2Extension = new Dictionary<sbyte, string>();
|
||||
inventory2Content = new Dictionary<sbyte, string>();
|
||||
content2Asset = new Dictionary<string, sbyte>();
|
||||
content2Inventory = new Dictionary<string, sbyte>();
|
||||
Dictionary<sbyte, string> asset2Contentd = [];
|
||||
Dictionary<sbyte, string> asset2Extensiond = [];
|
||||
Dictionary<sbyte, string> inventory2Contentd = [];
|
||||
Dictionary<string, sbyte> content2Assetd = [];
|
||||
Dictionary<string, sbyte> content2Inventoryd = [];
|
||||
|
||||
foreach (TypeMapping mapping in MAPPINGS)
|
||||
{
|
||||
sbyte assetType = mapping.AssetTypeCode;
|
||||
if (!asset2Content.ContainsKey(assetType))
|
||||
asset2Content.Add(assetType, mapping.ContentType);
|
||||
sbyte assetType = mapping.AssetType;
|
||||
asset2Contentd.TryAdd(assetType, mapping.ContentType);
|
||||
asset2Extensiond.TryAdd(assetType, mapping.Extension);
|
||||
|
||||
if (!asset2Extension.ContainsKey(assetType))
|
||||
asset2Extension.Add(assetType, mapping.Extension);
|
||||
inventory2Contentd.TryAdd(mapping.InventoryType, mapping.ContentType);
|
||||
|
||||
if (!inventory2Content.ContainsKey(mapping.InventoryType))
|
||||
inventory2Content.Add(mapping.InventoryType, mapping.ContentType);
|
||||
content2Assetd.TryAdd(mapping.ContentType, assetType);
|
||||
|
||||
if (!content2Asset.ContainsKey(mapping.ContentType))
|
||||
content2Asset.Add(mapping.ContentType, assetType);
|
||||
|
||||
if (!content2Inventory.ContainsKey(mapping.ContentType))
|
||||
content2Inventory.Add(mapping.ContentType, mapping.InventoryType);
|
||||
content2Inventoryd.TryAdd(mapping.ContentType, mapping.InventoryType);
|
||||
|
||||
if (mapping.ContentType2 != null)
|
||||
{
|
||||
if (!content2Asset.ContainsKey(mapping.ContentType2))
|
||||
content2Asset.Add(mapping.ContentType2, assetType);
|
||||
if (!content2Inventory.ContainsKey(mapping.ContentType2))
|
||||
content2Inventory.Add(mapping.ContentType2, mapping.InventoryType);
|
||||
content2Assetd.TryAdd(mapping.ContentType2, assetType);
|
||||
content2Inventoryd.TryAdd(mapping.ContentType2, mapping.InventoryType);
|
||||
}
|
||||
}
|
||||
asset2Content = asset2Contentd.ToFrozenDictionary();
|
||||
asset2Extension = asset2Extensiond.ToFrozenDictionary();
|
||||
inventory2Content = inventory2Contentd.ToFrozenDictionary();
|
||||
content2Asset = content2Assetd.ToFrozenDictionary();
|
||||
content2Inventory = content2Inventoryd.ToFrozenDictionary();
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static AssetType SLAssetName2Type(string name)
|
||||
{
|
||||
if (name2Asset.TryGetValue(name, out AssetType type))
|
||||
return type;
|
||||
return AssetType.Unknown;
|
||||
return name2Asset.TryGetValue(name, out AssetType type) ? type : AssetType.Unknown;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static FolderType SLInvName2Type(string name)
|
||||
{
|
||||
if (name2Inventory.TryGetValue(name, out FolderType type))
|
||||
return type;
|
||||
return FolderType.None;
|
||||
return name2Inventory.TryGetValue(name, out FolderType type) ? type : FolderType.None;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static string SLAssetTypeToContentType(int assetType)
|
||||
{
|
||||
string contentType;
|
||||
if (!asset2Content.TryGetValue((sbyte)assetType, out contentType))
|
||||
contentType = asset2Content[(sbyte)AssetType.Unknown];
|
||||
return contentType;
|
||||
return asset2Content.TryGetValue((sbyte)assetType, out string contentType) ? contentType : asset2Content[(sbyte)AssetType.Unknown];
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static string SLInvTypeToContentType(int invType)
|
||||
{
|
||||
string contentType;
|
||||
if (!inventory2Content.TryGetValue((sbyte)invType, out contentType))
|
||||
contentType = inventory2Content[(sbyte)InventoryType.Unknown];
|
||||
return contentType;
|
||||
return inventory2Content.TryGetValue((sbyte)invType, out string contentType) ? contentType : inventory2Content[(sbyte)InventoryType.Unknown];
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static sbyte ContentTypeToSLAssetType(string contentType)
|
||||
{
|
||||
sbyte assetType;
|
||||
if (!content2Asset.TryGetValue(contentType, out assetType))
|
||||
assetType = (sbyte)AssetType.Unknown;
|
||||
return (sbyte)assetType;
|
||||
return content2Asset.TryGetValue(contentType, out sbyte assetType) ? assetType : (sbyte)AssetType.Unknown;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static sbyte ContentTypeToSLInvType(string contentType)
|
||||
{
|
||||
sbyte invType;
|
||||
if (!content2Inventory.TryGetValue(contentType, out invType))
|
||||
invType = (sbyte)InventoryType.Unknown;
|
||||
return (sbyte)invType;
|
||||
return content2Inventory.TryGetValue(contentType, out sbyte invType) ? invType : (sbyte)InventoryType.Unknown;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static string SLAssetTypeToExtension(int assetType)
|
||||
{
|
||||
string extension;
|
||||
if (!asset2Extension.TryGetValue((sbyte)assetType, out extension))
|
||||
extension = asset2Extension[(sbyte)AssetType.Unknown];
|
||||
return extension;
|
||||
return asset2Extension.TryGetValue((sbyte)assetType, out string extension) ? extension : asset2Extension[(sbyte)AssetType.Unknown];
|
||||
}
|
||||
|
||||
#endregion SL / file extension / content-type conversions
|
||||
|
||||
static char[] seps = new char[] { '\t', '\n' };
|
||||
static char[] stringseps = new char[] { '|', '\n' };
|
||||
static readonly char[] seps = new char[] { '\t', '\n' };
|
||||
static readonly char[] stringseps = new char[] { '|', '\n' };
|
||||
|
||||
static byte[] moronize = new byte[16]
|
||||
{
|
||||
60, 17, 94, 81, 4, 244, 82, 60, 159, 166, 152, 175, 241, 3, 71, 48
|
||||
};
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
static int getField(string note, int start, string name, bool isString, out string value)
|
||||
{
|
||||
value = String.Empty;
|
||||
|
||||
@@ -29,7 +29,6 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using OpenMetaverse;
|
||||
using OpenSimAssetType = OpenSim.Framework.SLUtil.OpenSimAssetType;
|
||||
|
||||
namespace OpenSim.Framework.Serialization
|
||||
{
|
||||
@@ -125,7 +124,7 @@ namespace OpenSim.Framework.Serialization
|
||||
ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.SoundWAV] = ASSET_EXTENSION_SEPARATOR + "sound.wav";
|
||||
ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.Texture] = ASSET_EXTENSION_SEPARATOR + "texture.jp2";
|
||||
ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.TextureTGA] = ASSET_EXTENSION_SEPARATOR + "texture.tga";
|
||||
ASSET_TYPE_TO_EXTENSION[(sbyte)OpenSimAssetType.Material] = ASSET_EXTENSION_SEPARATOR + "material.xml";
|
||||
ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.OSMaterial] = ASSET_EXTENSION_SEPARATOR + "material.xml";
|
||||
ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.Settings] = ASSET_EXTENSION_SEPARATOR + "settings.bin";
|
||||
ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.Material] = ASSET_EXTENSION_SEPARATOR + "prmat.dat";
|
||||
|
||||
@@ -148,7 +147,7 @@ namespace OpenSim.Framework.Serialization
|
||||
EXTENSION_TO_ASSET_TYPE[ASSET_EXTENSION_SEPARATOR + "sound.wav"] = (sbyte)AssetType.SoundWAV;
|
||||
EXTENSION_TO_ASSET_TYPE[ASSET_EXTENSION_SEPARATOR + "texture.jp2"] = (sbyte)AssetType.Texture;
|
||||
EXTENSION_TO_ASSET_TYPE[ASSET_EXTENSION_SEPARATOR + "texture.tga"] = (sbyte)AssetType.TextureTGA;
|
||||
EXTENSION_TO_ASSET_TYPE[ASSET_EXTENSION_SEPARATOR + "material.xml"] = (sbyte)OpenSimAssetType.Material;
|
||||
EXTENSION_TO_ASSET_TYPE[ASSET_EXTENSION_SEPARATOR + "material.xml"] = (sbyte)AssetType.OSMaterial;
|
||||
EXTENSION_TO_ASSET_TYPE[ASSET_EXTENSION_SEPARATOR + "settings.bin"] = (sbyte)AssetType.Settings;
|
||||
EXTENSION_TO_ASSET_TYPE[ASSET_EXTENSION_SEPARATOR + "prmat.dat"] = (sbyte)AssetType.Material;
|
||||
}
|
||||
|
||||
@@ -33,84 +33,97 @@ using System.IO;
|
||||
using System.Net;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Web;
|
||||
using OSHttpServer;
|
||||
using log4net;
|
||||
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace OpenSim.Framework.Servers.HttpServer
|
||||
{
|
||||
public class OSHttpRequest : IOSHttpRequest
|
||||
{
|
||||
private static readonly ILog _log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
//private static readonly ILog _log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
protected IHttpRequest m_request = null;
|
||||
protected IHttpClientContext m_context = null;
|
||||
protected readonly IHttpRequest m_request = null;
|
||||
|
||||
public string[] AcceptTypes
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get { return m_request.AcceptTypes; }
|
||||
}
|
||||
|
||||
public Encoding ContentEncoding
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get { return m_contentEncoding; }
|
||||
}
|
||||
private Encoding m_contentEncoding;
|
||||
|
||||
public long ContentLength
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get { return m_request.ContentLength; }
|
||||
}
|
||||
|
||||
public long ContentLength64
|
||||
{
|
||||
get { return ContentLength; }
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get { return m_request.ContentLength; }
|
||||
}
|
||||
|
||||
public string ContentType
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get { return m_contentType; }
|
||||
}
|
||||
private string m_contentType;
|
||||
|
||||
public bool HasEntityBody
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get { return m_request.ContentLength != 0; }
|
||||
}
|
||||
|
||||
public NameValueCollection Headers
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get { return m_request.Headers; }
|
||||
}
|
||||
|
||||
public string HttpMethod
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get { return m_request.Method; }
|
||||
}
|
||||
|
||||
public Stream InputStream
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get { return m_request.Body; }
|
||||
}
|
||||
|
||||
public bool IsSecured
|
||||
{
|
||||
get { return m_context.IsSecured; }
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get { return m_request.Context.IsSecured; }
|
||||
}
|
||||
|
||||
public bool KeepAlive
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get { return ConnectionType.KeepAlive == m_request.Connection; }
|
||||
}
|
||||
|
||||
public NameValueCollection QueryString
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get { return m_request.QueryString;}
|
||||
}
|
||||
|
||||
private Hashtable m_queryAsHashtable = null;
|
||||
public Hashtable Query
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get
|
||||
{
|
||||
if (m_queryAsHashtable == null)
|
||||
@@ -123,6 +136,7 @@ namespace OpenSim.Framework.Servers.HttpServer
|
||||
private Dictionary<string, string> _queryAsDictionay = null;
|
||||
public Dictionary<string,string> QueryAsDictionary
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get
|
||||
{
|
||||
if (_queryAsDictionay == null)
|
||||
@@ -134,6 +148,7 @@ namespace OpenSim.Framework.Servers.HttpServer
|
||||
private HashSet<string> m_queryFlags = null;
|
||||
public HashSet<string> QueryFlags
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get
|
||||
{
|
||||
if (m_queryFlags == null)
|
||||
@@ -148,48 +163,57 @@ namespace OpenSim.Framework.Servers.HttpServer
|
||||
|
||||
public string RawUrl
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get { return m_request.Uri.AbsolutePath; }
|
||||
}
|
||||
|
||||
public IPEndPoint RemoteIPEndPoint
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get { return m_request.RemoteIPEndPoint; }
|
||||
}
|
||||
|
||||
public IPEndPoint LocalIPEndPoint
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get { return m_request.LocalIPEndPoint; }
|
||||
}
|
||||
|
||||
public Uri Url
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get { return m_request.Uri; }
|
||||
}
|
||||
|
||||
public string UriPath
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get { return m_request.UriPath; }
|
||||
}
|
||||
|
||||
public string UserAgent
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get { return m_userAgent; }
|
||||
}
|
||||
private string m_userAgent;
|
||||
|
||||
public double ArrivalTS
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get { return m_request.ArrivalTS;}
|
||||
}
|
||||
|
||||
internal IHttpRequest IHttpRequest
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get { return m_request; }
|
||||
}
|
||||
|
||||
internal IHttpClientContext IHttpClientContext
|
||||
{
|
||||
get { return m_context; }
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get { return m_request.Context; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -198,6 +222,7 @@ namespace OpenSim.Framework.Servers.HttpServer
|
||||
/// </summary>
|
||||
internal Dictionary<string, object> Whiteboard
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get { return _whiteboard; }
|
||||
}
|
||||
private Dictionary<string, object> _whiteboard = new Dictionary<string, object>();
|
||||
@@ -207,7 +232,6 @@ namespace OpenSim.Framework.Servers.HttpServer
|
||||
public OSHttpRequest(IHttpRequest req)
|
||||
{
|
||||
m_request = req;
|
||||
m_context = req.Context;
|
||||
|
||||
if (null != req.Headers["content-encoding"])
|
||||
{
|
||||
@@ -226,12 +250,12 @@ namespace OpenSim.Framework.Servers.HttpServer
|
||||
if (null != req.Headers["user-agent"])
|
||||
m_userAgent = req.Headers["user-agent"];
|
||||
|
||||
// Form = new Hashtable();
|
||||
// foreach (HttpInputItem item in req.Form)
|
||||
// {
|
||||
// _log.DebugFormat("[OSHttpRequest]: Got form item {0}={1}", item.Name, item.Value);
|
||||
// Form.Add(item.Name, item.Value);
|
||||
// }
|
||||
//Form = new Hashtable();
|
||||
//foreach (HttpInputItem item in req.Form)
|
||||
//{
|
||||
// _log.DebugFormat("[OSHttpRequest]: Got form item {0}={1}", item.Name, item.Value);
|
||||
// Form.Add(item.Name, item.Value);
|
||||
//}
|
||||
}
|
||||
|
||||
private void BuildQueryDictionary()
|
||||
@@ -239,7 +263,7 @@ namespace OpenSim.Framework.Servers.HttpServer
|
||||
NameValueCollection q = m_request.QueryString;
|
||||
_queryAsDictionay = new Dictionary<string, string>();
|
||||
m_queryFlags = new HashSet<string>();
|
||||
for(int i = 0; i <q.Count; ++i)
|
||||
for(int i = 0; i < q.Count; ++i)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -275,14 +299,14 @@ namespace OpenSim.Framework.Servers.HttpServer
|
||||
public override string ToString()
|
||||
{
|
||||
StringBuilder me = new StringBuilder();
|
||||
me.Append(String.Format("OSHttpRequest: {0} {1}\n", HttpMethod, RawUrl));
|
||||
me.Append($"OSHttpRequest: {HttpMethod} {RawUrl}\n");
|
||||
foreach (string k in Headers.AllKeys)
|
||||
{
|
||||
me.Append(String.Format(" {0}: {1}\n", k, Headers[k]));
|
||||
me.Append($" {k}: {Headers[k]}\n");
|
||||
}
|
||||
if (null != RemoteIPEndPoint)
|
||||
{
|
||||
me.Append(String.Format(" IP: {0}\n", RemoteIPEndPoint));
|
||||
me.Append($" IP: {RemoteIPEndPoint}\n");
|
||||
}
|
||||
|
||||
return me.ToString();
|
||||
|
||||
@@ -29,6 +29,7 @@ using System.IO;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using OSHttpServer;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace OpenSim.Framework.Servers.HttpServer
|
||||
{
|
||||
@@ -47,15 +48,11 @@ namespace OpenSim.Framework.Servers.HttpServer
|
||||
/// </remarks>
|
||||
public virtual string ContentType
|
||||
{
|
||||
get
|
||||
{
|
||||
return _httpResponse.ContentType;
|
||||
}
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get { return _httpResponse.ContentType; }
|
||||
|
||||
set
|
||||
{
|
||||
_httpResponse.ContentType = value;
|
||||
}
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
set { _httpResponse.ContentType = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -77,15 +74,11 @@ namespace OpenSim.Framework.Servers.HttpServer
|
||||
/// </summary>
|
||||
public long ContentLength
|
||||
{
|
||||
get
|
||||
{
|
||||
return _httpResponse.ContentLength;
|
||||
}
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get { return _httpResponse.ContentLength; }
|
||||
|
||||
set
|
||||
{
|
||||
_httpResponse.ContentLength = value;
|
||||
}
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
set { _httpResponse.ContentLength = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -93,7 +86,10 @@ namespace OpenSim.Framework.Servers.HttpServer
|
||||
/// </summary>
|
||||
public long ContentLength64
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get { return ContentLength; }
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
set { ContentLength = value; }
|
||||
}
|
||||
|
||||
@@ -102,31 +98,20 @@ namespace OpenSim.Framework.Servers.HttpServer
|
||||
/// </summary>
|
||||
public Encoding ContentEncoding
|
||||
{
|
||||
get
|
||||
{
|
||||
return _httpResponse.Encoding;
|
||||
}
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get { return _httpResponse.Encoding; }
|
||||
|
||||
set
|
||||
{
|
||||
_httpResponse.Encoding = value;
|
||||
}
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
set { _httpResponse.Encoding = value; }
|
||||
}
|
||||
|
||||
public bool KeepAlive
|
||||
{
|
||||
get
|
||||
{
|
||||
return _httpResponse.Connection == ConnectionType.KeepAlive;
|
||||
}
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get { return _httpResponse.Connection == ConnectionType.KeepAlive; }
|
||||
|
||||
set
|
||||
{
|
||||
if (value)
|
||||
_httpResponse.Connection = ConnectionType.KeepAlive;
|
||||
else
|
||||
_httpResponse.Connection = ConnectionType.Close;
|
||||
}
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
set { _httpResponse.Connection = value ? ConnectionType.KeepAlive : ConnectionType.Close; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -136,11 +121,10 @@ namespace OpenSim.Framework.Servers.HttpServer
|
||||
/// </summary>
|
||||
public int KeepAliveTimeout
|
||||
{
|
||||
get
|
||||
{
|
||||
return _httpResponse.KeepAlive;
|
||||
}
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get { return _httpResponse.KeepAlive; }
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
set
|
||||
{
|
||||
if (value == 0)
|
||||
@@ -148,7 +132,6 @@ namespace OpenSim.Framework.Servers.HttpServer
|
||||
_httpResponse.Connection = ConnectionType.Close;
|
||||
_httpResponse.KeepAlive = 0;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
_httpResponse.Connection = ConnectionType.KeepAlive;
|
||||
@@ -165,23 +148,17 @@ namespace OpenSim.Framework.Servers.HttpServer
|
||||
/// </remarks>
|
||||
public Stream OutputStream
|
||||
{
|
||||
get
|
||||
{
|
||||
return _httpResponse.Body;
|
||||
}
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get { return _httpResponse.Body; }
|
||||
}
|
||||
|
||||
public string ProtocolVersion
|
||||
{
|
||||
get
|
||||
{
|
||||
return _httpResponse.ProtocolVersion;
|
||||
}
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get { return _httpResponse.ProtocolVersion; }
|
||||
|
||||
set
|
||||
{
|
||||
_httpResponse.ProtocolVersion = value;
|
||||
}
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
set { _httpResponse.ProtocolVersion = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -189,58 +166,44 @@ namespace OpenSim.Framework.Servers.HttpServer
|
||||
/// </summary>
|
||||
public Stream Body
|
||||
{
|
||||
get
|
||||
{
|
||||
return _httpResponse.Body;
|
||||
}
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get { return _httpResponse.Body; }
|
||||
}
|
||||
|
||||
public byte[] RawBuffer
|
||||
{
|
||||
get
|
||||
{
|
||||
return _httpResponse.RawBuffer;
|
||||
}
|
||||
set
|
||||
{
|
||||
_httpResponse.RawBuffer = value;
|
||||
}
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get { return _httpResponse.RawBuffer; }
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
set { _httpResponse.RawBuffer = value; }
|
||||
}
|
||||
|
||||
public int RawBufferStart
|
||||
{
|
||||
get
|
||||
{
|
||||
return _httpResponse.RawBufferStart;
|
||||
}
|
||||
set
|
||||
{
|
||||
_httpResponse.RawBufferStart = value;
|
||||
}
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get { return _httpResponse.RawBufferStart; }
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
set { _httpResponse.RawBufferStart = value; }
|
||||
}
|
||||
|
||||
public int RawBufferLen
|
||||
{
|
||||
get
|
||||
{
|
||||
return _httpResponse.RawBufferLen;
|
||||
}
|
||||
set
|
||||
{
|
||||
_httpResponse.RawBufferLen = value;
|
||||
}
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get { return _httpResponse.RawBufferLen; }
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
set { _httpResponse.RawBufferLen = value; }
|
||||
}
|
||||
|
||||
public int Priority
|
||||
{
|
||||
get
|
||||
{
|
||||
return _httpResponse.Priority;
|
||||
}
|
||||
set
|
||||
{
|
||||
_httpResponse.Priority = value;
|
||||
}
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get { return _httpResponse.Priority; }
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
set { _httpResponse.Priority = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -248,15 +211,11 @@ namespace OpenSim.Framework.Servers.HttpServer
|
||||
/// </summary>
|
||||
public bool SendChunked
|
||||
{
|
||||
get
|
||||
{
|
||||
return _httpResponse.Chunked;
|
||||
}
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get { return _httpResponse.Chunked; }
|
||||
|
||||
set
|
||||
{
|
||||
_httpResponse.Chunked = value;
|
||||
}
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
set { _httpResponse.Chunked = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -264,20 +223,17 @@ namespace OpenSim.Framework.Servers.HttpServer
|
||||
/// </summary>
|
||||
public virtual int StatusCode
|
||||
{
|
||||
get
|
||||
{
|
||||
return (int)_httpResponse.Status;
|
||||
}
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get { return (int)_httpResponse.Status; }
|
||||
|
||||
set
|
||||
{
|
||||
_httpResponse.Status = (HttpStatusCode)value;
|
||||
}
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
set { _httpResponse.Status = (HttpStatusCode)value; }
|
||||
}
|
||||
|
||||
public double RequestTS
|
||||
{
|
||||
get {return _httpResponse.RequestTS; }
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get { return _httpResponse.RequestTS; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -285,18 +241,14 @@ namespace OpenSim.Framework.Servers.HttpServer
|
||||
/// </summary>
|
||||
public string StatusDescription
|
||||
{
|
||||
get
|
||||
{
|
||||
return _httpResponse.Reason;
|
||||
}
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get { return _httpResponse.Reason; }
|
||||
|
||||
set
|
||||
{
|
||||
_httpResponse.Reason = value;
|
||||
}
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
set { _httpResponse.Reason = value; }
|
||||
}
|
||||
|
||||
protected IHttpResponse _httpResponse;
|
||||
protected readonly IHttpResponse _httpResponse;
|
||||
|
||||
public OSHttpResponse() {}
|
||||
|
||||
@@ -326,6 +278,7 @@ namespace OpenSim.Framework.Servers.HttpServer
|
||||
/// </summary>
|
||||
/// <param name="url">redirection target url</param>
|
||||
/// <param name="redirStatusCode">the response Status, must be Found, Redirect, Moved,MovedPermanently,RedirectKeepVerb, RedirectMethod, TemporaryRedirect. Defaults to Redirect</param>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void Redirect(string url, HttpStatusCode redirStatusCode = HttpStatusCode.Redirect)
|
||||
{
|
||||
_httpResponse.Redirect(url, redirStatusCode);
|
||||
@@ -338,6 +291,7 @@ namespace OpenSim.Framework.Servers.HttpServer
|
||||
/// name</param>
|
||||
/// <param name="value">string containing the header field
|
||||
/// value</param>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void AddHeader(string key, string value)
|
||||
{
|
||||
_httpResponse.AddHeader(key, value);
|
||||
@@ -346,6 +300,7 @@ namespace OpenSim.Framework.Servers.HttpServer
|
||||
/// <summary>
|
||||
/// Send the response back to the remote client
|
||||
/// </summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void Send()
|
||||
{
|
||||
_httpResponse.Chunked = false;
|
||||
|
||||
Reference in New Issue
Block a user