Home Dashboard Directory Help
Search

Invoke-WebRequest should rewind the RawContentStream by Joel 'Jaykul' Bennett


Status: 

Active


4
0
Sign in
to vote
Type: Suggestion
ID: 807797
Opened: 11/5/2013 11:08:51 AM
Access Restriction: Public
0
Workaround(s)
view

Description

The object that's output from Invoke-WebRequest has a "RawContentStream" which is a memory stream that has a copy of the network stream received in the response. However, it's pointer is left at the end of the stream (where it naturally is, after the content has been copied), which means that anyone wanting to read the stream has to first seek the stream to the beginning.

Invoke-WebRequest should move the location to the beginning of the stream before returning, to make it easier to use the stream from Powershell (avoiding this):

$null = $WebResponse.RawContentStream.Seek(0,"Begin")

There's virtually no risk to fixing it, since basically every possible use of that stream currently requires resetting it, and resetting it twice wouldn't hurt anything anyway.
Details
Sign in to post a comment.
Sign in to post a workaround.