8000 WebRequestPSCmdlets do not contain Response object in Exception on Mac OS X · Issue #2113 · PowerShell/PowerShell · GitHub
[go: up one dir, main page]

Skip to content
WebRequestPSCmdlets do not contain Response object in Exception on Mac OS X #2113
@ffeldhaus

Description

@ffeldhaus

When running either Invoke-WebRequest or Invoke-RestMethod against a server returning an HTTP error code (e.g. 404), PowerShell 5 on Windows throws an exception which contains a response object. In PowerShell 6 on Mac OS X the response object is not available.

Steps to reproduce

Invoke-WebRequest http://httpbin.org/404 
$Error[0].Exception.Response

Expected behavior

The expected behaviour is, that the exception contains a response as HttpWebResponse object:

PS C:\> $Error[0].Exception.Response

IsMutuallyAuthenticated : False
Cookies                 : {}
Headers                 : {Connection, Access-Control-Allow-Origin, Access-Control-Allow-Credentials, Content-Length...}
SupportsHeaders         : True
ContentLength           : 233
ContentEncoding         : 
ContentType             : text/html
CharacterSet            : ISO-8859-1
Server                  : nginx
LastModified            : 8/29/2016 12:47:17 AM
StatusCode              : NotFound
StatusDescription       : NOT FOUND
ProtocolVersion         : 1.1
ResponseUri             : http://httpbin.org/404
Method                  : GET
IsFromCache             : False

Actual behavior

PS /> $Error[0].Exception.Response
PS /> 

Environment data

Name                           Value                                                                                                                                                                                                         
----                           -----                                                                                                                                                                                                         
PSVersion                      6.0.0-alpha                                                                                                                                                                                                   
PSEdition                      Core                                                                                                                                                                                                          
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}                                                                                                                                                                                       
BuildVersion                   3.0.0.0                                                                                                                                                                                                       
GitCommitId                    v6.0.0-alpha.9                                                                                                                                                                                                
CLRVersion                                                                                                                                                                                                                                   
WSManStackVersion              3.0                                                                                                                                                                                                           
PSRemotingProtocolVersion      2.3                                                                                                                                                                                                           
SerializationVersion           1.1.0.1 

Metadata

Metadata

Assignees

Labels

Issue-BugIssue has been identified as a bug in the productResolution-FixedThe issue is fixed.WG-Cmdletsgeneral cmdlet issues

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions

    0