mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
Fix webcmdlets to properly construct URI from body when using -NoProxy (#14673)
This commit is contained in:
+2
-2
@@ -815,12 +815,12 @@ namespace Microsoft.PowerShell.Commands
|
||||
|
||||
private bool IsStandardMethodSet()
|
||||
{
|
||||
return (ParameterSetName == "StandardMethod");
|
||||
return (ParameterSetName == "StandardMethod" || ParameterSetName == "StandardMethodNoProxy");
|
||||
}
|
||||
|
||||
private bool IsCustomMethodSet()
|
||||
{
|
||||
return (ParameterSetName == "CustomMethod");
|
||||
return (ParameterSetName == "CustomMethod" || ParameterSetName == "CustomMethodNoProxy");
|
||||
}
|
||||
|
||||
private string GetBasicAuthorizationHeader()
|
||||
|
||||
@@ -688,6 +688,13 @@ Describe "Invoke-WebRequest tests" -Tags "Feature", "RequireAdminOnWindows" {
|
||||
($result.Output.Content | ConvertFrom-Json).args.testparam | Should -Be "testvalue"
|
||||
}
|
||||
|
||||
It "Validate Invoke-WebRequest body is converted to query params for CustomMethod GET and -NoProxy" {
|
||||
$uri = Get-WebListenerUrl -Test 'Get'
|
||||
$command = "Invoke-WebRequest -Uri '$uri' -CustomMethod GET -Body @{'testparam'='testvalue'} -NoProxy"
|
||||
$result = ExecuteWebCommand -command $command
|
||||
($result.Output.Content | ConvertFrom-Json).query | Should -Be "?testparam=testvalue"
|
||||
}
|
||||
|
||||
It "Validate Invoke-WebRequest returns HTTP errors in exception" {
|
||||
$query = @{
|
||||
body = "I am a teapot!!!"
|
||||
@@ -2269,6 +2276,13 @@ Describe "Invoke-RestMethod tests" -Tags "Feature", "RequireAdminOnWindows" {
|
||||
$result.Output.args.testparam | Should -Be "testvalue"
|
||||
}
|
||||
|
||||
It "Validate Invoke-RestMethod body is converted to query params for CustomMethod GET and -NoProxy" {
|
||||
$uri = Get-WebListenerUrl -Test 'Get'
|
||||
$command = "Invoke-RestMethod -Uri '$uri' -CustomMethod GET -Body @{'testparam'='testvalue'} -NoProxy"
|
||||
$result = ExecuteWebCommand -command $command
|
||||
$result.Output.Query | Should -Be "?testparam=testvalue"
|
||||
}
|
||||
|
||||
It "Validate Invoke-RestMethod returns HTTP errors in exception" {
|
||||
$query = @{
|
||||
body = "I am a teapot!!!"
|
||||
|
||||
@@ -36,6 +36,7 @@ namespace mvc.Controllers
|
||||
{"headers", headers},
|
||||
{"origin" , Request.HttpContext.Connection.RemoteIpAddress.ToString()},
|
||||
{"url" , UriHelper.GetDisplayUrl(Request)},
|
||||
{"query" , Request.QueryString.ToUriComponent()},
|
||||
{"method" , Request.Method}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user