[Modify] Throw exceptions
This commit is contained in:
parent
da2287229e
commit
d3a8582d92
@ -770,16 +770,19 @@ namespace WebSocketSharp.Server
|
|||||||
/// </param>
|
/// </param>
|
||||||
public bool TryGetServiceHost (string path, out WebSocketServiceHost host)
|
public bool TryGetServiceHost (string path, out WebSocketServiceHost host)
|
||||||
{
|
{
|
||||||
host = null;
|
if (path == null)
|
||||||
|
throw new ArgumentNullException ("path");
|
||||||
|
|
||||||
if (path == null || path.Length == 0)
|
if (path.Length == 0)
|
||||||
return false;
|
throw new ArgumentException ("An empty string.", "path");
|
||||||
|
|
||||||
if (path[0] != '/')
|
if (path[0] != '/')
|
||||||
return false;
|
throw new ArgumentException ("Not an absolute path.", "path");
|
||||||
|
|
||||||
if (path.IndexOfAny (new[] { '?', '#' }) > -1)
|
if (path.IndexOfAny (new[] { '?', '#' }) > -1) {
|
||||||
return false;
|
var msg = "It includes either or both query and fragment components.";
|
||||||
|
throw new ArgumentException (msg, "path");
|
||||||
|
}
|
||||||
|
|
||||||
return InternalTryGetServiceHost (path, out host);
|
return InternalTryGetServiceHost (path, out host);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user