-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Closed
Labels
Resolution-AnsweredThe question is answered.The question is answered.WG-Cmdlets-Utilitycmdlets in the Microsoft.PowerShell.Utility modulecmdlets in the Microsoft.PowerShell.Utility module
Description
The Content-Type header appears to be missing everywhere except $response.BaseResponse.Content.Headers.ContentType. it is even being removed from $response.RawContent . it happens regardless of using -UseBasicParsing or not, regardless of -method and regardless of -UserAgent.
Steps to reproduce
Describe 'Invoke-WebRequest' {
Context 'Response: Content-Type Header' {
$Uri = 'http://httpbin.org/headers'
$response = Invoke-WebRequest -Uri $Uri
It "Has BaseResponse.Content.Headers.ContentType" {
$response.BaseResponse.Content.Headers.ContentType |
Should Not BeNullOrEmpty
}
It "Has Headers.'Content-Type'" {
$response.Headers.ContainsKey('Content-Type') | Should Be $True
$response.Headers.'Content-Type' | Should Not BeNullOrEmpty
}
It "Has BaseResponse.Headers.'Content-Type'" {
$response.BaseResponse.Headers.Keys -contains 'Content-Type' | Should Be $True
$response.BaseResponse.Headers.Get('Content-Type') | Should Not BeNullOrEmpty
}
It "Has BaseResponse.ContentType" {
$response.BaseResponse.ContentType | Should Not BeNullOrEmpty
}
It "Has Content-Type in the RawContent" {
$response.RawContent -match 'Content-Type' | Should Be $True
}
}
}Expected behavior
Describing Invoke-WebRequest
Context Response: Content-Type Header
[+] Has BaseResponse.Content.Headers.ContentType.MediaType 12.62s
[+] Has Headers.'Content-Type' 11.36s
[+] Has BaseResponse.Headers.'Content-Type' 28ms
[+] Has BaseResponse.ContentType 10ms
[+] Has Content-Type in the RawContent 18ms
Actual behavior
Describing Invoke-WebRequest
Context Response: Content-Type Header
[+] Has BaseResponse.Content.Headers.ContentType 13.59s
[-] Has Headers.'Content-Type' 42ms
Expected: {True}
But was: {False}
at line: 10 in
10: $response.Headers.ContainsKey('Content-Type') | Should Be $True
[-] Has BaseResponse.Headers.'Content-Type' 23ms
Expected: {True}
But was: {False}
at line: 14 in
14: $response.BaseResponse.Headers.Keys -contains 'Content-Type' | Should Be $True
[-] Has BaseResponse.ContentType 24ms
Expected: value to not be empty
at line: 18 in
18: $response.BaseResponse.ContentType | Should Not BeNullOrEmpty
[-] Has Content-Type in the RawContent 28ms
Expected: {True}
But was: {False}
at line: 21 in
21: $response.RawContent -match 'Content-Type' | Should Be $True
Environment data
> $PSVersionTable
Name Value
---- -----
PSVersion 6.0.0-beta
PSEdition Core
GitCommitId v6.0.0-beta.4
OS Microsoft Windows 10.0.15063
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0Metadata
Metadata
Assignees
Labels
Resolution-AnsweredThe question is answered.The question is answered.WG-Cmdlets-Utilitycmdlets in the Microsoft.PowerShell.Utility modulecmdlets in the Microsoft.PowerShell.Utility module