Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1172,7 +1172,7 @@ internal virtual void FillRequestStream(HttpRequestMessage request)
{
WebSession.ContentHeaders[HttpKnownHeaderNames.ContentType] = ContentType;
}
else if (request.Method == HttpMethod.Post || request.Method == HttpMethod.Put)
else if (request.Method == HttpMethod.Post)
{
// Win8:545310 Invoke-WebRequest does not properly set MIME type for POST
WebSession.ContentHeaders.TryGetValue(HttpKnownHeaderNames.ContentType, out string contentType);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -795,14 +795,9 @@ Describe "Invoke-WebRequest tests" -Tags "Feature", "RequireAdminOnWindows" {
($result.Output.Content | ConvertFrom-Json).method | Should -Be "TEST"
}

It "Validate Invoke-WebRequest default ContentType for CustomMethod <method>" -TestCases @(
@{method = "POST"}
@{method = "PUT"}
) {
param($method)

$uri = Get-WebListenerUrl -Test $method
$command = "Invoke-WebRequest -Uri '$uri' -CustomMethod $method -Body 'testparam=testvalue'"
It "Validate Invoke-WebRequest default ContentType for CustomMethod POST" {
$uri = Get-WebListenerUrl -Test 'Post'
$command = "Invoke-WebRequest -Uri '$uri' -CustomMethod POST -Body 'testparam=testvalue'"
$result = ExecuteWebCommand -command $command
$jsonResult = $result.Output.Content | ConvertFrom-Json
$jsonResult.form.testparam | Should -Be "testvalue"
Expand Down Expand Up @@ -2845,13 +2840,9 @@ Describe "Invoke-RestMethod tests" -Tags "Feature", "RequireAdminOnWindows" {
$result.Output.method | Should -Be "TEST"
}

It "Validate Invoke-RestMethod default ContentType for CustomMethod <method>" -TestCases @(
@{method = "POST"}
@{method = "PUT"}
) {
param($method)
$uri = Get-WebListenerUrl -Test $method
$command = "Invoke-RestMethod -Uri '$uri' -CustomMethod $method -Body 'testparam=testvalue'"
It "Validate Invoke-RestMethod default ContentType for CustomMethod POST" {
$uri = Get-WebListenerUrl -Test 'Post'
$command = "Invoke-RestMethod -Uri '$uri' -CustomMethod POST -Body 'testparam=testvalue'"
$result = ExecuteWebCommand -command $command
$result.Output.form.testparam | Should -Be "testvalue"
$result.Output.Headers.'Content-Type' | Should -Be "application/x-www-form-urlencoded"
Expand Down