Skip to content

Headers of WebResponseObject object are returned as Array of String instead of String #13378

@barry-luijten

Description

@barry-luijten

Problem description

The headers of Microsoft.PowerShell.Commands.BasicHtmlWebResponseObject object returned by Invoke-WebRequest, are returned as Arrays of String instead of String.
This problem seems specific to the Headers dictionary of the WebResponse object.

Steps to reproduce

$r = Invoke-WebRequest -Uri "https://www.microsoft.com/en-us/"
$r.Headers['Content-Type'].GetType()

Expected behavior

On Powershell 5.1:

IsPublic IsSerial Name                                     BaseType
-------- -------- ----                                     --------
True     True     String                                   System.Object

Actual behavior

IsPublic IsSerial Name                                     BaseType
-------- -------- ----                                     --------
True     True     String[]                                 System.Array

Environment data

Name                           Value
----                           -----
PSVersion                      7.0.3
PSEdition                      Core
GitCommitId                    7.0.3
OS                             Linux 3.10.0-1127.10.1.el7.x86_64 #1 SMP Tue May 26 15:05:43 EDT 2020
Platform                       Unix
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-Questionideally support can be provided via other mechanisms, but sometimes folks do open an issue to get aResolution-AnsweredThe question is answered.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions