mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
Fix using xml -Body in webcmdlets without an encoding (#19281)
This commit is contained in:
@@ -588,6 +588,15 @@ Describe "Invoke-WebRequest tests" -Tags "Feature", "RequireAdminOnWindows" {
|
||||
$object.Data | Should -BeExactly 'проверка'
|
||||
}
|
||||
|
||||
It "Invoke-WebRequest supports sending XML requests without encoding" {
|
||||
$uri = Get-WebListenerUrl -Test POST
|
||||
$body = '<?xml version="1.0"?><foo />'
|
||||
$result = Invoke-WebRequest -Uri $uri -body ([xml]$body) -ContentType 'text/xml' -method 'POST'
|
||||
|
||||
$object = $result.Content | ConvertFrom-Json
|
||||
$object.Data | Should -BeExactly $body
|
||||
}
|
||||
|
||||
It "Invoke-WebRequest supports request that returns page containing CodPage 936 data." {
|
||||
$uri = Get-WebListenerUrl -Test 'Encoding' -TestValue 'CP936'
|
||||
$command = "Invoke-WebRequest -Uri '$uri'"
|
||||
@@ -2402,6 +2411,14 @@ Describe "Invoke-RestMethod tests" -Tags "Feature", "RequireAdminOnWindows" {
|
||||
$Result.Output.Data | Should -BeExactly 'проверка'
|
||||
}
|
||||
|
||||
It "Invoke-RestMethod supports sending XML requests without encoding" {
|
||||
$uri = Get-WebListenerUrl -Test POST
|
||||
$body = '<?xml version="1.0"?><foo />'
|
||||
$result = Invoke-RestMethod -Uri $uri -body ([xml]$body) -ContentType 'text/xml' -method 'POST'
|
||||
|
||||
$result.Data | Should -BeExactly $body
|
||||
}
|
||||
|
||||
It "Invoke-RestMethod supports request that returns page containing Code Page 936 data." {
|
||||
$uri = Get-WebListenerUrl -Test 'Encoding' -TestValue 'CP936'
|
||||
$command = "Invoke-RestMethod -Uri '$uri'"
|
||||
|
||||
Reference in New Issue
Block a user