mirror of
https://github.com/OpenSim-NGC/OpenSim-Sasquatch.git
synced 2024-11-21 06:26:09 -07:00
cosmetics
This commit is contained in:
parent
604282c482
commit
f447a58ac9
3 changed files with 112 additions and 137 deletions
|
@ -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()
|
||||
|
@ -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;
|
||||
|
|
|
@ -113,14 +113,10 @@ namespace OpenSim.Region.ClientStack.LindenCaps
|
|||
public void RegisterCaps(UUID agentID, Caps caps)
|
||||
{
|
||||
string capPath = "/" + UUID.Random();
|
||||
caps.RegisterSimpleHandler("ServerReleaseNotes",
|
||||
new SimpleStreamHandler(capPath, delegate (IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
|
||||
{
|
||||
ProcessServerReleaseNotes(httpResponse);
|
||||
}));
|
||||
caps.RegisterSimpleHandler("ServerReleaseNotes", new SimpleStreamHandler(capPath, ProcessServerReleaseNotes));
|
||||
}
|
||||
|
||||
private void ProcessServerReleaseNotes(IOSHttpResponse httpResponse)
|
||||
public void ProcessServerReleaseNotes(IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
|
||||
{
|
||||
httpResponse.Redirect(m_ServerReleaseNotesURL);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue