[Modify] Polish it

To initialize.
This commit is contained in:
sta 2017-11-13 15:08:56 +09:00
parent 0d3be42f00
commit fdfc127530

View File

@ -3866,26 +3866,23 @@ namespace WebSocketSharp
throw new InvalidOperationException (msg); throw new InvalidOperationException (msg);
} }
if (url == null) Uri uri = null;
throw new ArgumentNullException ("url");
if (url.Length == 0) if (!url.IsNullOrEmpty ()) {
throw new ArgumentException ("An empty string.", "url"); if (!Uri.TryCreate (url, UriKind.Absolute, out uri)) {
msg = "Not an absolute URI string.";
throw new ArgumentException (msg, "url");
}
Uri uri; if (uri.Scheme != "http") {
if (!Uri.TryCreate (url, UriKind.Absolute, out uri)) { msg = "The scheme part is not http.";
msg = "Not an absolute URI string."; throw new ArgumentException (msg, "url");
throw new ArgumentException (msg, "url"); }
}
if (uri.Scheme != "http") { if (uri.Segments.Length > 1) {
msg = "The scheme part is not http."; msg = "It includes the path segments.";
throw new ArgumentException (msg, "url"); throw new ArgumentException (msg, "url");
} }
if (uri.Segments.Length > 1) {
msg = "It includes the path segments.";
throw new ArgumentException (msg, "url");
} }
if (!username.IsNullOrEmpty ()) { if (!username.IsNullOrEmpty ()) {
@ -3913,6 +3910,13 @@ namespace WebSocketSharp
return; return;
} }
if (url.IsNullOrEmpty ()) {
_proxyUri = null;
_proxyCredentials = null;
return;
}
_proxyUri = uri; _proxyUri = uri;
_proxyCredentials = !username.IsNullOrEmpty () _proxyCredentials = !username.IsNullOrEmpty ()
? new NetworkCredential ( ? new NetworkCredential (