GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — Add -SkipHeaderValidation switch to Invoke-WebRequest and Invoke-RestMethod to support adding headers without validating the header value. by dantraMSFT · Pull Request #4085 · PowerShell/PowerShell Conversation
|
|
You need to rebase and only include the commits for this PR |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Rebased. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Looks like you accidentally added whitespace
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Will fix
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I updated the file and removed all trailing whitespace per the using-vscode.md to get the file to a 'clean' state.
note that when I diff my version against powershell/master, the only whitespace difference I see is at line 172 where trailing whitespace was removed. I don't see any of the other whitespace differences that the online diff viewer is reporting.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Local and online diff sometimes surprise us.
Here may be a real difference in 'rn' and ``n`.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Use the ShouldBeErrorId pattern https://github.com/PowerShell/PowerShell/search?utf8=%E2%9C%93&q=ShouldBeErrorId&type=
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I can't use ShouldBeErrorId for those statements; it expects a ScriptBlock to execute and throw an exception.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Ok
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Use the ShouldBeErrorId pattern
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
ShouldBeErrorId does not work here; it expects a script block and then catches the exception to verify the error id.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Ok
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
"echo" doesn't seem to be necessary as "response" basically does the same thing. I would suggest updating "response" if you want json (perhaps based on "contenttype"
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Changing "response" to use JSON for the output breaks many tests. I will update the comment for echo but won't change response at this time.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I'm not suggesting always return json. "response" takes a contenttype argument you can use.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I think it makes more sense to have a separate 'echo' test. The returned data for response would be very different; it currently doesn't echo the request, and using contentype to control that doesn't make sense to me.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
ok
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Travis Plunk (@TravisEz13) please merge this PR. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Dan Travison (@dantraMSFT) Please resolve merge conflicts |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
…Method to support adding headers without validating the header value.
|
Travis Plunk (@TravisEz13): Conflicts resolved. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Dan Travison (@dantraMSFT) You used an "email address" to commit which is not associated with your GitHub account. Please add the association. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
PR has change
|
Steve Lee (@SteveL-MSFT), please reapprove this PR. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Travis Plunk (@TravisEz13): Can you look at this? Steve is out until next week. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| $headers = @{"If-Match" = "*"} | ||
| $response = ExecuteRequestWithCustomHeaders -Uri "http://localhost:8080/PowerShell?test=echo" -headers $headers | ||
|
|
||
| $response.Error | Should BeNullOrEmpty |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
We can remove this - next line makes the check.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
The check is intentional. Checking for $result.Error provides a better failure id if the underlying request fails versus the NullReferenceException that would occur in the next statement.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I believe NullReferenceException would occur only if we call a method but we call a property.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
You're right but the end result does not change. If the request does not complete successfully, I want to know that. Testing the content doesn't help me diagnose that and, in fact, obfuscates it.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Thanks for clarify!
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| $headers = @{"If-Match" = "12345"} | ||
| $response = ExecuteRequestWithCustomHeaders -Uri "http://localhost:8080/PowerShell?test=echo" -headers $headers | ||
|
|
||
| $response.Error | Should Not BeNullOrEmpty |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Tha same.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
The check is intentional. Checking for $result.Error provides a better failure id if the underlying request fails versus the NullReferenceException that would occur in the next statement.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| $headers = @{"If-Match" = "12345"} | ||
| $response = ExecuteRequestWithCustomHeaders -Uri "http://localhost:8080/PowerShell?test=echo" -headers $headers -SkipHeaderValidation | ||
|
|
||
| $response.Error | Should BeNullOrEmpty |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
The same.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
The check is intentional. Checking for $result.Error provides a better failure id if the underlying request fails versus the NullReferenceException that would occur in the next statement.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| $headers = @{"If-Match" = "*"} | ||
| $response = ExecuteRequestWithCustomHeaders -Uri "http://localhost:8081/PowerShell?test=echo" -headers $headers -Cmdlet "Invoke-RestMethod" | ||
|
|
||
| $response.Error | Should BeNullOrEmpty |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Tha same.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| $headers = @{"If-Match" = "12345"} | ||
| $response = ExecuteRequestWithCustomHeaders -Uri "http://localhost:8081/PowerShell?test=echo" -headers $headers -Cmdlet "Invoke-RestMethod" | ||
|
|
||
| $response.Error | Should Not BeNullOrEmpty |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
The same.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
The check is intentional. Checking for $result.Error provides a better failure id if the underlying request fails versus the NullReferenceException that would occur in the next statement.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| $headers = @{"If-Match" = "12345"} | ||
| $response = ExecuteRequestWithCustomHeaders -Uri "http://localhost:8081/PowerShell?test=echo" -headers $headers -SkipHeaderValidation -Cmdlet "Invoke-RestMethod" | ||
|
|
||
| $response.Error | Should BeNullOrEmpty |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
The same.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
The check is intentional. Checking for $result.Error provides a better failure id if the underlying request fails versus the NullReferenceException that would occur in the next statement.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Thanks everyone |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
…Method to support adding headers without validating the header value. (PowerShell#4085) * Add -SkipHeaderValidation switch to Invoke-WebRequest and Invoke-RestMethod to support adding headers without validating the header value. * Fix whitespace
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
invoke-webrequest and invoke-restmethod -headers parameter is more restrictive on PowerShell Core than on PowerShell Native
There was an error while loading. Please reload this page.