Platform should return cross platform values under PSUserAgent#4945
Closed
chunqingchen wants to merge 1 commit intoPowerShell:masterfrom
Closed
Platform should return cross platform values under PSUserAgent#4945chunqingchen wants to merge 1 commit intoPowerShell:masterfrom
chunqingchen wants to merge 1 commit intoPowerShell:masterfrom
Conversation
markekraus
suggested changes
Sep 29, 2017
| { | ||
| return ("Windows NT"); | ||
| OperatingSystem osInfo = Environment.OSVersion; | ||
| return (osInfo.Platform.ToString()); |
Contributor
There was a problem hiding this comment.
This wont work. System.Platformid does not contain commonly accepted values for the platform part of a User-Agent header. For example, macOS should be Macintosh and all (recent) Windows should be Windows NT, and most Linux should be Linux or X11.
|
|
||
| } | ||
|
|
||
| It "User Agent should reflect current plafformID" { |
Contributor
There was a problem hiding this comment.
This test should be in test/powershell/Modules/Microsoft.PowerShell.Utility/WebCmdlets.Tests.ps1
|
|
||
| It "User Agent should reflect current plafformID" { | ||
| $bingdings = [System.Reflection.BindingFlags]::NonPublic -bxor [System.Reflection.BindingFlags]::Static | ||
| $platform = [Microsoft.PowerShell.Commands.PSUserAgent].GetProperty('Platform',$bingdings).GetValue($null,$null) |
Contributor
There was a problem hiding this comment.
We should probably not use reflection. Instead we should make a web call and ensure the User-Agent request header contains the desired data.
Collaborator
|
@chunqingchen Sorry, It is dup of #4937 |
Member
|
@chunqingchen I will close this PR as it's a duplicate of #4937 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
resolve #4913
Repro:
$bingdings = [System.Reflection.BindingFlags]::NonPublic -bxor [System.Reflection.BindingFlags]::Static
[Microsoft.PowerShell.Commands.PSUserAgent].GetProperty('Platform',$bingdings).GetValue($null,$null)
Before fix:
the returned string is fixed to "WindowsNT"
After fix:
the returned string is the current OS's platformID