-
Notifications
You must be signed in to change notification settings - Fork 524
Throw if UseUrls specifies HTTPS or path base (#1519) #1533
Conversation
{ | ||
throw new InvalidOperationException($"HTTPS addresses are not supported. Use {nameof(KestrelServerOptions)}.{nameof(KestrelServerOptions.Listen)}() to configure an HTTPS endpoint."); | ||
} | ||
|
||
if (!string.IsNullOrEmpty(parsedAddress.PathBase)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens if it's just '/'?
Where does it throw? This just logs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a ServerAddress
test that checks that just '/' is not set as path base:
KestrelHttpServer/test/Microsoft.AspNetCore.Server.KestrelTests/ServerAddressTests.cs
Line 42 in 632780d
[InlineData("http://www.example.com/", "http", "www.example.com", 80, "", "http://www.example.com:80")] |
@@ -164,9 +164,14 @@ public void Start<TContext>(IHttpApplication<TContext> application) | |||
{ | |||
var parsedAddress = ServerAddress.FromUrl(address); | |||
|
|||
if (parsedAddress.Scheme.Equals("https", StringComparison.OrdinalIgnoreCase)) | |||
{ | |||
throw new InvalidOperationException($"HTTPS addresses are not supported. Use {nameof(KestrelServerOptions)}.{nameof(KestrelServerOptions.Listen)}() to configure an HTTPS endpoint."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't like the phrasing of "HTTPS addresses are not supported..."
I would change this to "HTTPS endpoints may only be configured using {nameof(KestrelServerOptions)}.{nameof(KestrelServerOptions.Listen)}()".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
may?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can, must, whatever.
@halter73 I've changed the path base message too, for consistency. |
Does this incidentally fix #1296 too? |
@natemcmaster No. See my updated comment there. |
Updated. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
#1519