add request QueryFlags

master
UbitUmarov 2020-04-13 15:01:04 +01:00
parent b419f71a68
commit 920a26eeec
3 changed files with 68 additions and 43 deletions

View File

@ -52,6 +52,7 @@ namespace OpenSim.Framework.Servers.HttpServer
bool KeepAlive { get; } bool KeepAlive { get; }
NameValueCollection QueryString { get; } NameValueCollection QueryString { get; }
Hashtable Query { get; } Hashtable Query { get; }
HashSet<string> QueryFlags { get; }
Dictionary<string, string> QueryAsDictionary { get; } //faster than Query Dictionary<string, string> QueryAsDictionary { get; } //faster than Query
string RawUrl { get; } string RawUrl { get; }
IPEndPoint RemoteIPEndPoint { get; } IPEndPoint RemoteIPEndPoint { get; }

View File

@ -43,23 +43,23 @@ namespace OpenSim.Framework.Servers.HttpServer
{ {
private static readonly ILog _log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private static readonly ILog _log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
protected IHttpRequest _request = null; protected IHttpRequest m_request = null;
protected IHttpClientContext _context = null; protected IHttpClientContext m_context = null;
public string[] AcceptTypes public string[] AcceptTypes
{ {
get { return _request.AcceptTypes; } get { return m_request.AcceptTypes; }
} }
public Encoding ContentEncoding public Encoding ContentEncoding
{ {
get { return _contentEncoding; } get { return m_contentEncoding; }
} }
private Encoding _contentEncoding; private Encoding m_contentEncoding;
public long ContentLength public long ContentLength
{ {
get { return _request.ContentLength; } get { return m_request.ContentLength; }
} }
public long ContentLength64 public long ContentLength64
@ -69,15 +69,15 @@ namespace OpenSim.Framework.Servers.HttpServer
public string ContentType public string ContentType
{ {
get { return _contentType; } get { return m_contentType; }
} }
private string _contentType; private string m_contentType;
public HttpCookieCollection Cookies public HttpCookieCollection Cookies
{ {
get get
{ {
RequestCookies cookies = _request.Cookies; RequestCookies cookies = m_request.Cookies;
HttpCookieCollection httpCookies = new HttpCookieCollection(); HttpCookieCollection httpCookies = new HttpCookieCollection();
if(cookies != null) if(cookies != null)
{ {
@ -90,47 +90,47 @@ namespace OpenSim.Framework.Servers.HttpServer
public bool HasEntityBody public bool HasEntityBody
{ {
get { return _request.ContentLength != 0; } get { return m_request.ContentLength != 0; }
} }
public NameValueCollection Headers public NameValueCollection Headers
{ {
get { return _request.Headers; } get { return m_request.Headers; }
} }
public string HttpMethod public string HttpMethod
{ {
get { return _request.Method; } get { return m_request.Method; }
} }
public Stream InputStream public Stream InputStream
{ {
get { return _request.Body; } get { return m_request.Body; }
} }
public bool IsSecured public bool IsSecured
{ {
get { return _context.IsSecured; } get { return m_context.IsSecured; }
} }
public bool KeepAlive public bool KeepAlive
{ {
get { return ConnectionType.KeepAlive == _request.Connection; } get { return ConnectionType.KeepAlive == m_request.Connection; }
} }
public NameValueCollection QueryString public NameValueCollection QueryString
{ {
get { return _request.QueryString;} get { return m_request.QueryString;}
} }
private Hashtable _queryAsHashtable = null; private Hashtable m_queryAsHashtable = null;
public Hashtable Query public Hashtable Query
{ {
get get
{ {
if (_queryAsHashtable == null) if (m_queryAsHashtable == null)
BuildQueryHashtable(); BuildQueryHashtable();
return _queryAsHashtable; return m_queryAsHashtable;
} }
} }
@ -146,45 +146,55 @@ namespace OpenSim.Framework.Servers.HttpServer
} }
} }
/// <value> private HashSet<string> m_queryFlags = null;
/// POST request values, if applicable public HashSet<string> QueryFlags
/// </value>
// public Hashtable Form { get; private set; }
public string RawUrl
{ {
get { return _request.Uri.AbsolutePath; } get
{
if (m_queryFlags == null)
BuildQueryDictionary();
return m_queryFlags;
}
}
/// <value>
/// POST request values, if applicable
/// </value>
// public Hashtable Form { get; private set; }
public string RawUrl
{
get { return m_request.Uri.AbsolutePath; }
} }
public IPEndPoint RemoteIPEndPoint public IPEndPoint RemoteIPEndPoint
{ {
get { return _request.RemoteIPEndPoint; } get { return m_request.RemoteIPEndPoint; }
} }
public IPEndPoint LocalIPEndPoint public IPEndPoint LocalIPEndPoint
{ {
get { return _request.LocalIPEndPoint; } get { return m_request.LocalIPEndPoint; }
} }
public Uri Url public Uri Url
{ {
get { return _request.Uri; } get { return m_request.Uri; }
} }
public string UserAgent public string UserAgent
{ {
get { return _userAgent; } get { return m_userAgent; }
} }
private string _userAgent; private string m_userAgent;
internal IHttpRequest IHttpRequest internal IHttpRequest IHttpRequest
{ {
get { return _request; } get { return m_request; }
} }
internal IHttpClientContext IHttpClientContext internal IHttpClientContext IHttpClientContext
{ {
get { return _context; } get { return m_context; }
} }
/// <summary> /// <summary>
@ -201,14 +211,14 @@ namespace OpenSim.Framework.Servers.HttpServer
public OSHttpRequest(IHttpClientContext context, IHttpRequest req) public OSHttpRequest(IHttpClientContext context, IHttpRequest req)
{ {
_request = req; m_request = req;
_context = context; m_context = context;
if (null != req.Headers["content-encoding"]) if (null != req.Headers["content-encoding"])
{ {
try try
{ {
_contentEncoding = Encoding.GetEncoding(_request.Headers["content-encoding"]); m_contentEncoding = Encoding.GetEncoding(m_request.Headers["content-encoding"]);
} }
catch catch
{ {
@ -217,9 +227,9 @@ namespace OpenSim.Framework.Servers.HttpServer
} }
if (null != req.Headers["content-type"]) if (null != req.Headers["content-type"])
_contentType = _request.Headers["content-type"]; m_contentType = m_request.Headers["content-type"];
if (null != req.Headers["user-agent"]) if (null != req.Headers["user-agent"])
_userAgent = req.Headers["user-agent"]; m_userAgent = req.Headers["user-agent"];
// Form = new Hashtable(); // Form = new Hashtable();
// foreach (HttpInputItem item in req.Form) // foreach (HttpInputItem item in req.Form)
@ -231,8 +241,9 @@ namespace OpenSim.Framework.Servers.HttpServer
private void BuildQueryDictionary() private void BuildQueryDictionary()
{ {
NameValueCollection q = _request.QueryString; NameValueCollection q = m_request.QueryString;
_queryAsDictionay = new Dictionary<string, string>(); // only key value pairs _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 try
@ -240,6 +251,8 @@ namespace OpenSim.Framework.Servers.HttpServer
var name = q.GetKey(i); var name = q.GetKey(i);
if(!string.IsNullOrEmpty(name)) if(!string.IsNullOrEmpty(name))
_queryAsDictionay[name] = q[i]; _queryAsDictionay[name] = q[i];
else
m_queryFlags.Add(q[i]);
} }
catch {} catch {}
} }
@ -247,15 +260,18 @@ namespace OpenSim.Framework.Servers.HttpServer
private void BuildQueryHashtable() private void BuildQueryHashtable()
{ {
NameValueCollection q = _request.QueryString; NameValueCollection q = m_request.QueryString;
_queryAsHashtable = new Hashtable(); m_queryAsHashtable = new Hashtable();
m_queryFlags = new HashSet<string>();
for (int i = 0; i < q.Count; ++i) for (int i = 0; i < q.Count; ++i)
{ {
try try
{ {
var name = q.GetKey(i); var name = q.GetKey(i);
if (!string.IsNullOrEmpty(name)) if (!string.IsNullOrEmpty(name))
_queryAsDictionay[name] = q[i]; m_queryAsHashtable[name] = q[i];
else
m_queryFlags.Add(q[i]);
} }
catch { } catch { }
} }

View File

@ -153,6 +153,14 @@ namespace OpenSim.Tests.Common
} }
} }
public HashSet<string> QueryFlags
{
get
{
throw new NotImplementedException();
}
}
public string RawUrl public string RawUrl
{ {
get get