-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Remove comment and simplify condition in WebCmdlets #19251
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
Remove comment and simplify condition in WebCmdlets #19251
Conversation
@@ -904,8 +904,6 @@ internal virtual void PrepareSession() | |||
} | |||
else if (ProxyUseDefaultCredentials) | |||
{ | |||
// If both ProxyCredential and ProxyUseDefaultCredentials are passed, | |||
// UseDefaultCredentials will overwrite the supplied credentials. | |||
webProxy.UseDefaultCredentials = true; |
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.
Hmm, I think really the comment is correct since we can iwr -UseDefaultCredentials:$false -Credentials $cred
Perhaps it makes sense to remove the if
else
{
// If both ProxyCredential and ProxyUseDefaultCredentials are passed,
// UseDefaultCredentials will overwrite the supplied credentials.
webProxy.UseDefaultCredentials = ProxyUseDefaultCredentials;
}
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.
No this is wrong, we have both -Credentials
-UseDefaultCredentials
(for Authentication) and -ProxyCredentials
-ProxyUseDefaultCredentials
(for Proxy)
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 updated my proposal above.
Also please remove last commit as unrelated the PR.
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.
Cases:
iwr -Proxy $proxy
#GOOD proxy with no credentials
iwr -Proxy $proxy -ProxyCredential $credentials
#GOOD proxy with credentials
iwr -Proxy $proxy -ProxyUseDefaultCredentials:$true
#GOOD proxy with default credentials
iwr -Proxy $proxy -ProxyUseDefaultCredentials:$false
#GOOD proxy with no credentials
iwr -Proxy $proxy -ProxyCredential $credentials -ProxyUseDefaultCredentials:$true
#ERROR conflicting parameters
iwr -Proxy $proxy -ProxyCredential $credentials -ProxyUseDefaultCredentials:$false
#GOOD but redundant proxy with credentials
iwr -ProxyCredential $credentials -ProxyUseDefaultCredentials
#ERROR no proxy
I think we could implement your proposal but it won't change the current behaviour and we should still remove the comment
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.
It seems the comment is not add critical information. So I suggest:
else
{
webProxy.UseDefaultCredentials = ProxyUseDefaultCredentials;
}
This PR has Quantification details
Why proper sizing of changes matters
Optimal pull request sizes drive a better predictable PR flow as they strike a
What can I do to optimize my changes
How to interpret the change counts in git diff output
Was this comment helpful? 👍 :ok_hand: :thumbsdown: (Email) |
🎉 Handy links: |
PR Summary
Remove wrong comment.
We can't use both parameters toghether because of
ValidateParameters()
line 736PR Context
Found in #19173 @iSazonov @stevenebutler
PR Checklist
.h
,.cpp
,.cs
,.ps1
and.psm1
files have the correct copyright headerWIP:
or[ WIP ]
to the beginning of the title (theWIP
bot will keep its status check atPending
while the prefix is present) and remove the prefix when the PR is ready.(which runs in a different PS Host).