-
Notifications
You must be signed in to change notification settings - Fork 7.2k
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
Fix decompression in web cmdlets #17955
Conversation
|
||
# Validate response content | ||
$headers.'Content-Encoding'[0] | Should -BeExactly $dataEncoding | ||
# If Content is compressed we cannot read it as JSON. |
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 understand this comment. Do we need to convert content from json similar to above at line 601?
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 think this comment is saying that if the content wasn't decompressed correctly then it wouldn't be valid JSON so the test would fail? If that is case, perhaps the comment should make that more clear.
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.
@SteveL-MSFT What about:
# If Content is compressed we cannot read it as JSON. | |
# If Content is still compressed we cannot read it as JSON. |
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.
The thing is, there is no convertto-json
call following this comment, so the comment doesn't seem to make sense.
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.
Comment updated.
Overall, these changes look Ok to me. But I don't know what prompted this PR. Did the tests begin failing at some point? Or is this just code clean up to remove the current workaround and instead use the built-in automatic decompression setting? |
@PaulHigin The Then the cmdlets return the response without Second issue was with tests. I tried to keep them as near to original as possible. But I started to check with httpbin.org. The site send another response than our WebListener. httpbin.org response has a flag for used decompression method, WebListener haven't. I don't know how enhance WebListener. So I had to change tests. I don't know why our tests passed before the PR for deflate. I did not investigate either a root is in WebListener or in old workaround. |
This pull request has been automatically marked as Review Needed because it has been there has not been any activity for 7 days. |
This pull request has been automatically marked as Review Needed because it has been there has not been any activity for 7 days. |
src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/StreamHelper.cs
Show resolved
Hide resolved
test/powershell/Modules/Microsoft.PowerShell.Utility/WebCmdlets.Tests.ps1
Outdated
Show resolved
Hide resolved
|
||
# Validate response content | ||
$headers.'Content-Encoding'[0] | Should -BeExactly $dataEncoding | ||
# If Content is compressed we cannot read it as JSON. |
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.
The thing is, there is no convertto-json
call following this comment, so the comment doesn't seem to make sense.
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, with one suggestion.
test/powershell/Modules/Microsoft.PowerShell.Utility/WebCmdlets.Tests.ps1
Outdated
Show resolved
Hide resolved
…s.Tests.ps1 Co-authored-by: Dongbo Wang <dongbow@microsoft.com>
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) |
@PaulHigin Can you please take another look? |
This PR also fixes |
Is this going to make it into 7.4? |
It is already in v7.4.0-preview.1 |
Oh, cool. Normally a bot responds to the PR saying if it made it in or whatever. |
PR Summary
Follow doesn't work for original cmdlet:
I don't know why our tests are passed.
I guess there was something changed .Net from early versions.
The fix removes old workaround and turn on embedded automatic decompression in HttpClient handler.
PR Context
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).