Repository: PowerShell/PowerShell
File: test/powershell/Modules/Microsoft.PowerShell.Utility/WebCmdlets.Tests.ps1 (PowerShell)

Code before:
                $result.Output.headers.'Content-Type' | Should -Match $contentType

                # Validate that the response Content.data field is the same as what we sent.
                $result.Output.data | Should -Be $body
            }

            It "Invoke-RestMethod -Uri $uri -Method $method -Body [body data]" {

                $result = ExecuteWebCommand -command $commandNoContentType

                # Validate response
                $result.Output.url | Should -Match $uri

                if ($method -eq "POST")
                {
                    $result.Output.headers.'Content-Type' | Should -Match "application/x-www-form-urlencoded"
                    # Validate that the response Content.form field is the same as what we sent.
                    [string]$result.Output.form | Should -Be ([string][PSCustomObject]@{$body.Split("=")[0] = [System.Object[]]})
                    $result.Output.data | Should -BeNullOrEmpty
                }
                else
                {
                    # Validate that the response Content.data field is the same as what we sent.
                    $result.Output.data | Should -Be $body
                }

            }
        }
    }

    It "Validate Invoke-RestMethod -Headers --> Set KeepAlive to false via headers" {
        $uri = Get-WebListenerUrl -Test 'Get'
        $result = ExecuteRequestWithHeaders -cmdletName Invoke-RestMethod -uri $uri

        # Validate response
        $result.Output.url | Should -Match $uri
        $result.Output.Headers.Connection | Should -Be "Close"
    }

    # Validate all available user agents for Invoke-RestMethod
    $agents = @{
        InternetExplorer = "MSIE 9.0"
        Chrome           = "Chrome"
        Opera            = "Opera"
        Safari           = "Safari"
        FireFox          = "Firefox"
    }

    foreach ($agentName in $agents.Keys) {
        $expectedAgent = $agents[$agentName]
        $uri = Get-WebListenerUrl -Test 'Get'

Review comment (suggestion):
Please remove extra empty line.
```suggestion
```

Code after:
                $result.Output.headers.'Content-Type' | Should -Match $contentType

                # Validate that the response Content.data field is the same as what we sent.
                $result.Output.data | Should -Be $body
            }

            It "Invoke-RestMethod -Uri $uri -Method $method -Body [body data]" {

                $result = ExecuteWebCommand -command $commandNoContentType

                # Validate response
                $result.Output.url | Should -Match $uri

                if ($method -eq "POST")
                {
                    $result.Output.headers.'Content-Type' | Should -Match "application/x-www-form-urlencoded"
                    # Validate that the response Content.form field is the same as what we sent.
                    [string]$result.Output.form | Should -Be ([string][PSCustomObject]@{$body.Split("=")[0] = [System.Object[]]})
                    $result.Output.data | Should -BeNullOrEmpty
                }
                else
                {
                    # Validate that the response Content.data field is the same as what we sent.
                    $result.Output.data | Should -Be $body
                }
            }
        }
    }

    It "Validate Invoke-RestMethod -Headers --> Set KeepAlive to false via headers" {
        $uri = Get-WebListenerUrl -Test 'Get'
        $result = ExecuteRequestWithHeaders -cmdletName Invoke-RestMethod -uri $uri

        # Validate response
        $result.Output.url | Should -Match $uri
        $result.Output.Headers.Connection | Should -Be "Close"
    }

    # Validate all available user agents for Invoke-RestMethod
    $agents = @{
        InternetExplorer = "MSIE 9.0"
        Chrome           = "Chrome"
        Opera            = "Opera"
        Safari           = "Safari"
        FireFox          = "Firefox"
    }

    foreach ($agentName in $agents.Keys) {
        $expectedAgent = $agents[$agentName]
        $uri = Get-WebListenerUrl -Test 'Get'
        $userAgent = "[Microsoft.PowerShell.Commands.PSUserAgent]::$agentName"