change osrequest Query back to hashtable, add QueryAsDictionary as new better option. (recover compatibily with current external modules

master
UbitUmarov 2020-04-13 14:24:22 +01:00
parent 745a469af8
commit e0ba96055c
3 changed files with 51 additions and 10 deletions

View File

@ -51,7 +51,8 @@ namespace OpenSim.Framework.Servers.HttpServer
bool IsSecured { get; } bool IsSecured { get; }
bool KeepAlive { get; } bool KeepAlive { get; }
NameValueCollection QueryString { get; } NameValueCollection QueryString { get; }
Dictionary<string, string> Query { get; } Hashtable Query { get; }
Dictionary<string, string> QueryAsDictionary { get; } //faster than Query
string RawUrl { get; } string RawUrl { get; }
IPEndPoint RemoteIPEndPoint { get; } IPEndPoint RemoteIPEndPoint { get; }
Uri Url { get; } Uri Url { get; }

View File

@ -123,17 +123,28 @@ namespace OpenSim.Framework.Servers.HttpServer
get { return _request.QueryString;} get { return _request.QueryString;}
} }
public Dictionary<string,string> Query private Hashtable _queryAsHashtable = null;
public Hashtable Query
{ {
get get
{ {
if (_queryKeyValues == null) if (_queryAsHashtable == null)
BuildQueryDictionary(); BuildQueryHashtable();
return _queryKeyValues; return _queryAsHashtable;
} }
} }
private Dictionary<string, string> _queryKeyValues = null; //faster than Query
private Dictionary<string, string> _queryAsDictionay = null;
public Dictionary<string,string> QueryAsDictionary
{
get
{
if (_queryAsDictionay == null)
BuildQueryDictionary();
return _queryAsDictionay;
}
}
/// <value> /// <value>
/// POST request values, if applicable /// POST request values, if applicable
@ -150,6 +161,11 @@ namespace OpenSim.Framework.Servers.HttpServer
get { return _request.RemoteIPEndPoint; } get { return _request.RemoteIPEndPoint; }
} }
public IPEndPoint LocalIPEndPoint
{
get { return _request.LocalIPEndPoint; }
}
public Uri Url public Uri Url
{ {
get { return _request.Uri; } get { return _request.Uri; }
@ -216,19 +232,35 @@ namespace OpenSim.Framework.Servers.HttpServer
private void BuildQueryDictionary() private void BuildQueryDictionary()
{ {
NameValueCollection q = _request.QueryString; NameValueCollection q = _request.QueryString;
_queryKeyValues = new Dictionary<string, string>(); // only key value pairs _queryAsDictionay = new Dictionary<string, string>(); // only key value pairs
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))
_queryKeyValues[name] = q[i]; _queryAsDictionay[name] = q[i];
} }
catch {} catch {}
} }
} }
private void BuildQueryHashtable()
{
NameValueCollection q = _request.QueryString;
_queryAsHashtable = new Hashtable();
for (int i = 0; i < q.Count; ++i)
{
try
{
var name = q.GetKey(i);
if (!string.IsNullOrEmpty(name))
_queryAsDictionay[name] = q[i];
}
catch { }
}
}
public override string ToString() public override string ToString()
{ {
StringBuilder me = new StringBuilder(); StringBuilder me = new StringBuilder();

View File

@ -137,11 +137,19 @@ namespace OpenSim.Tests.Common
} }
} }
public Dictionary<string,string> Query public Hashtable Query
{ {
get get
{ {
throw new NotImplementedException (); throw new NotImplementedException();
}
}
public Dictionary<string, string> QueryAsDictionary
{
get
{
throw new NotImplementedException();
} }
} }