[Modify] Polish it

This commit is contained in:
sta 2017-06-07 15:36:22 +09:00
parent f0d03cefcb
commit 2a0479c634

View File

@ -1037,45 +1037,46 @@ namespace WebSocketSharp.Server
_receiveThread.Join (millisecondsTimeout); _receiveThread.Join (millisecondsTimeout);
} }
private static bool tryCreateUri (string uriString, out Uri result, out string message) private static bool tryCreateUri (
string uriString, out Uri result, out string message
)
{ {
result = null; result = null;
message = null;
var uri = uriString.ToUri (); var uri = uriString.ToUri ();
if (uri == null) { if (uri == null) {
message = "An invalid URI string: " + uriString; message = "An invalid URI string.";
return false; return false;
} }
if (!uri.IsAbsoluteUri) { if (!uri.IsAbsoluteUri) {
message = "Not an absolute URI: " + uriString; message = "A relative URI.";
return false; return false;
} }
var schm = uri.Scheme; var schm = uri.Scheme;
if (!(schm == "http" || schm == "https")) { if (!(schm == "http" || schm == "https")) {
message = "The scheme part isn't 'http' or 'https': " + uriString; message = "The scheme part is not 'http' or 'https'.";
return false; return false;
} }
if (uri.PathAndQuery != "/") { if (uri.PathAndQuery != "/") {
message = "Includes the path or query component: " + uriString; message = "It includes either or both path and query components.";
return false; return false;
} }
if (uri.Fragment.Length > 0) { if (uri.Fragment.Length > 0) {
message = "Includes the fragment component: " + uriString; message = "It includes the fragment component.";
return false; return false;
} }
if (uri.Port == 0) { if (uri.Port == 0) {
message = "The port part is zero: " + uriString; message = "The port part is zero.";
return false; return false;
} }
result = uri; result = uri;
message = String.Empty;
return true; return true;
} }