|
|
|
@ -312,6 +312,7 @@ namespace WebSocketSharp.Net
|
|
|
|
private HttpListener searchListener (Uri uri, out HttpListenerPrefix prefix)
|
|
|
|
private HttpListener searchListener (Uri uri, out HttpListenerPrefix prefix)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
prefix = null;
|
|
|
|
prefix = null;
|
|
|
|
|
|
|
|
|
|
|
|
if (uri == null)
|
|
|
|
if (uri == null)
|
|
|
|
return null;
|
|
|
|
return null;
|
|
|
|
|
|
|
|
|
|
|
|
@ -319,27 +320,30 @@ namespace WebSocketSharp.Net
|
|
|
|
var dns = Uri.CheckHostName (host) == UriHostNameType.Dns;
|
|
|
|
var dns = Uri.CheckHostName (host) == UriHostNameType.Dns;
|
|
|
|
var port = uri.Port.ToString ();
|
|
|
|
var port = uri.Port.ToString ();
|
|
|
|
var path = HttpUtility.UrlDecode (uri.AbsolutePath);
|
|
|
|
var path = HttpUtility.UrlDecode (uri.AbsolutePath);
|
|
|
|
var pathSlash = path[path.Length - 1] == '/' ? path : path + "/";
|
|
|
|
var pathSlash = path[path.Length - 1] != '/' ? path + "/" : path;
|
|
|
|
|
|
|
|
|
|
|
|
HttpListener bestMatch = null;
|
|
|
|
HttpListener bestMatch = null;
|
|
|
|
var bestLen = -1;
|
|
|
|
|
|
|
|
if (host != null && host.Length > 0) {
|
|
|
|
if (host != null && host.Length > 0) {
|
|
|
|
|
|
|
|
var bestLen = -1;
|
|
|
|
foreach (var pref in _prefixes.Keys) {
|
|
|
|
foreach (var pref in _prefixes.Keys) {
|
|
|
|
var ppath = pref.Path;
|
|
|
|
if (dns) {
|
|
|
|
if (ppath.Length < bestLen)
|
|
|
|
var prefHost = pref.Host;
|
|
|
|
continue;
|
|
|
|
if (Uri.CheckHostName (prefHost) == UriHostNameType.Dns && prefHost != host)
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (pref.Port != port)
|
|
|
|
if (pref.Port != port)
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
|
|
if (dns) {
|
|
|
|
var prefPath = pref.Path;
|
|
|
|
var phost = pref.Host;
|
|
|
|
|
|
|
|
if (Uri.CheckHostName (phost) == UriHostNameType.Dns && phost != host)
|
|
|
|
var len = prefPath.Length;
|
|
|
|
continue;
|
|
|
|
if (len < bestLen)
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
|
|
if (path.StartsWith (ppath) || pathSlash.StartsWith (ppath)) {
|
|
|
|
if (path.StartsWith (prefPath) || pathSlash.StartsWith (prefPath)) {
|
|
|
|
bestLen = ppath.Length;
|
|
|
|
bestLen = len;
|
|
|
|
bestMatch = _prefixes[pref];
|
|
|
|
bestMatch = _prefixes[pref];
|
|
|
|
prefix = pref;
|
|
|
|
prefix = pref;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -362,10 +366,7 @@ namespace WebSocketSharp.Net
|
|
|
|
if (path != pathSlash && bestMatch == null)
|
|
|
|
if (path != pathSlash && bestMatch == null)
|
|
|
|
bestMatch = matchFromList (host, pathSlash, list, out prefix);
|
|
|
|
bestMatch = matchFromList (host, pathSlash, list, out prefix);
|
|
|
|
|
|
|
|
|
|
|
|
if (bestMatch != null)
|
|
|
|
return bestMatch;
|
|
|
|
return bestMatch;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
#endregion
|
|
|
|
|