Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

WebRequestPSCmdlets do not contain Response object in Exception on Mac OS X #2113

Copy link
Copy link
@ffeldhaus

Description

@ffeldhaus
Issue body actions

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 
Reactions are currently unavailable

Metadata

Metadata

Assignees

Labels

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

Type

No type
No fields configured for issues without a type.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions

    Morty Proxy This is a proxified and sanitized view of the page, visit original site.