-
Notifications
You must be signed in to change notification settings - Fork 4.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use IndexOfAny in HttpListener.HandleAuthentication #71137
Conversation
Tagging subscribers to this area: @dotnet/ncl Issue DetailsJust cleaning up a manual loop that can instead be IndexOfAny.
|
looks related |
src/libraries/System.Net.HttpListener/src/System/Net/Windows/HttpListener.Windows.cs
Show resolved
Hide resolved
Just cleaning up a manual loop that can instead be IndexOfAny.
fe46e14
to
fd88434
Compare
fd88434
to
1724769
Compare
{ | ||
break; | ||
} | ||
index = authorizationHeader.Length; |
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.
This will work. But I think this is only used in the condition bellow to guard if any character was found. e.g. you can simplify that without assignment as
- if (index < authorizationHeader.Length)
+ if (index >= 0)
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.
index
is also referenced later in the method.
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.
yeah, I missed that reading it on GH. However, without going to the first block, headerScheme should remain AuthenticationSchemes.None
and we will error out without reaching the next index
use. Not sure if HttpListener is worth of any more troubles.
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
Just cleaning up a manual loop that can instead be IndexOfAny.