Fix for pull request #133, allow port 443 with non secure scheme, and allow port 80 with secure scheme

This commit is contained in:
sta
2015-06-30 15:43:00 +09:00
parent cb8d1e75f6
commit 2078bfad5a
3 changed files with 27 additions and 58 deletions

View File

@@ -104,12 +104,8 @@ namespace WebSocketSharp.Server
/// <paramref name="port"/> isn't between 1 and 65535 inclusive.
/// </exception>
public HttpServer (int port)
: this (port, port == 443)
{
if (!port.IsPortNumber ())
throw new ArgumentOutOfRangeException (
"port", "Not between 1 and 65535 inclusive: " + port);
init ("*", port, port == 443);
}
/// <summary>
@@ -127,9 +123,6 @@ namespace WebSocketSharp.Server
/// A <see cref="bool"/> that indicates providing a secure connection or not.
/// (<c>true</c> indicates providing a secure connection.)
/// </param>
/// <exception cref="ArgumentException">
/// Pair of <paramref name="port"/> and <paramref name="secure"/> is invalid.
/// </exception>
/// <exception cref="ArgumentOutOfRangeException">
/// <paramref name="port"/> isn't between 1 and 65535 inclusive.
/// </exception>
@@ -139,10 +132,6 @@ namespace WebSocketSharp.Server
throw new ArgumentOutOfRangeException (
"port", "Not between 1 and 65535 inclusive: " + port);
if ((port == 80 && secure) || (port == 443 && !secure))
throw new ArgumentException (
String.Format ("An invalid pair of 'port' and 'secure': {0}, {1}", port, secure));
init ("*", port, secure);
}

View File

@@ -112,12 +112,8 @@ namespace WebSocketSharp.Server
/// <paramref name="port"/> isn't between 1 and 65535 inclusive.
/// </exception>
public WebSocketServer (int port)
: this (port, port == 443)
{
if (!port.IsPortNumber ())
throw new ArgumentOutOfRangeException (
"port", "Not between 1 and 65535 inclusive: " + port);
init (System.Net.IPAddress.Any, port, port == 443);
}
/// <summary>
@@ -188,15 +184,16 @@ namespace WebSocketSharp.Server
/// A <see cref="bool"/> that indicates providing a secure connection or not.
/// (<c>true</c> indicates providing a secure connection.)
/// </param>
/// <exception cref="ArgumentException">
/// Pair of <paramref name="port"/> and <paramref name="secure"/> is invalid.
/// </exception>
/// <exception cref="ArgumentOutOfRangeException">
/// <paramref name="port"/> isn't between 1 and 65535 inclusive.
/// </exception>
public WebSocketServer (int port, bool secure)
: this (System.Net.IPAddress.Any, port, secure)
{
if (!port.IsPortNumber ())
throw new ArgumentOutOfRangeException (
"port", "Not between 1 and 65535 inclusive: " + port);
init (System.Net.IPAddress.Any, port, secure);
}
/// <summary>
@@ -255,15 +252,7 @@ namespace WebSocketSharp.Server
/// <paramref name="address"/> is <see langword="null"/>.
/// </exception>
/// <exception cref="ArgumentException">
/// <para>
/// <paramref name="address"/> isn't a local IP address.
/// </para>
/// <para>
/// -or-
/// </para>
/// <para>
/// Pair of <paramref name="port"/> and <paramref name="secure"/> is invalid.
/// </para>
/// <paramref name="address"/> isn't a local IP address.
/// </exception>
/// <exception cref="ArgumentOutOfRangeException">
/// <paramref name="port"/> isn't between 1 and 65535 inclusive.
@@ -280,10 +269,6 @@ namespace WebSocketSharp.Server
throw new ArgumentOutOfRangeException (
"port", "Not between 1 and 65535 inclusive: " + port);
if ((port == 80 && secure) || (port == 443 && !secure))
throw new ArgumentException (
String.Format ("An invalid pair of 'port' and 'secure': {0}, {1}", port, secure));
init (address, port, secure);
}