[Modify] Polish it

This commit is contained in:
sta 2020-09-28 21:58:35 +09:00
parent 9ec4a086d3
commit 30e576297b

View File

@ -83,6 +83,7 @@ namespace WebSocketSharp.Net
var pref = new HttpListenerPrefix (uriPrefix); var pref = new HttpListenerPrefix (uriPrefix);
var addr = convertToIPAddress (pref.Host); var addr = convertToIPAddress (pref.Host);
if (addr == null) if (addr == null)
throw new HttpListenerException (87, "Includes an invalid host."); throw new HttpListenerException (87, "Includes an invalid host.");
@ -90,6 +91,7 @@ namespace WebSocketSharp.Net
throw new HttpListenerException (87, "Includes an invalid host."); throw new HttpListenerException (87, "Includes an invalid host.");
int port; int port;
if (!Int32.TryParse (pref.Port, out port)) if (!Int32.TryParse (pref.Port, out port))
throw new HttpListenerException (87, "Includes an invalid port."); throw new HttpListenerException (87, "Includes an invalid port.");
@ -97,6 +99,7 @@ namespace WebSocketSharp.Net
throw new HttpListenerException (87, "Includes an invalid port."); throw new HttpListenerException (87, "Includes an invalid port.");
var path = pref.Path; var path = pref.Path;
if (path.IndexOf ('%') != -1) if (path.IndexOf ('%') != -1)
throw new HttpListenerException (87, "Includes an invalid path."); throw new HttpListenerException (87, "Includes an invalid path.");
@ -106,19 +109,19 @@ namespace WebSocketSharp.Net
var endpoint = new IPEndPoint (addr, port); var endpoint = new IPEndPoint (addr, port);
EndPointListener lsnr; EndPointListener lsnr;
if (_endpoints.TryGetValue (endpoint, out lsnr)) { if (_endpoints.TryGetValue (endpoint, out lsnr)) {
if (lsnr.IsSecure ^ pref.IsSecure) if (lsnr.IsSecure ^ pref.IsSecure)
throw new HttpListenerException (87, "Includes an invalid scheme."); throw new HttpListenerException (87, "Includes an invalid scheme.");
} }
else { else {
lsnr = lsnr = new EndPointListener (
new EndPointListener ( endpoint,
endpoint, pref.IsSecure,
pref.IsSecure, listener.CertificateFolderPath,
listener.CertificateFolderPath, listener.SslConfiguration,
listener.SslConfiguration, listener.ReuseAddress
listener.ReuseAddress );
);
_endpoints.Add (endpoint, lsnr); _endpoints.Add (endpoint, lsnr);
} }