NotSupportedException for forward-only reading of unseekable ConnectStream #118

Closed
opened 2026-01-29 22:06:51 +00:00 by claunia · 5 comments
Owner

Originally created by @AlexVallat on GitHub (Aug 12, 2016).

When using ZipReader over the ConnectStream obtained from a HttpWebResponse, it fails at the second call of MoveToNextEntry due to attempting to access the .Position of the underlying stream. ConnectStream does not support .Position as it does not support seeking.

Originally created by @AlexVallat on GitHub (Aug 12, 2016). When using ZipReader over the ConnectStream obtained from a HttpWebResponse, it fails at the second call of MoveToNextEntry due to attempting to access the .Position of the underlying stream. ConnectStream does not support .Position as it does not support seeking.
Author
Owner

@adamhathcock commented on GitHub (Aug 12, 2016):

Can you give me the full stack trace? It definitely shouldn't be doing that.

@adamhathcock commented on GitHub (Aug 12, 2016): Can you give me the full stack trace? It definitely shouldn't be doing that.
Author
Owner

@adamhathcock commented on GitHub (Aug 12, 2016):

Never mind, I reproduced it.

@adamhathcock commented on GitHub (Aug 12, 2016): Never mind, I reproduced it.
Author
Owner

@AlexVallat commented on GitHub (Aug 12, 2016):

Just in case, I might as well post the stack anyway now that I've captured it:

System.NotSupportedException: This stream does not support seek operations.
   at System.Net.ConnectStream.get_Position()
   at SharpCompress.IO.NonDisposingStream.get_Position() in d:\dev\SharpCompress\src\SharpCompress\IO\NonDisposingStream.cs:line 46
   at SharpCompress.IO.RewindableStream.get_Position() in d:\dev\SharpCompress\src\SharpCompress\IO\RewindableStream.cs:line 97
   at SharpCompress.Common.Zip.StreamingZipHeaderFactory.<ReadStreamHeader>d__0.MoveNext() in d:\dev\SharpCompress\src\SharpCompress\Common\Zip\StreamingZipHeaderFactory.cs:line 34
   at SharpCompress.Reader.Zip.ZipReader.<GetEntries>d__0.MoveNext() in d:\dev\SharpCompress\src\SharpCompress\Reader\Zip\ZipReader.cs:line 46
   at SharpCompress.Reader.AbstractReader`2.NextEntryForCurrentStream() in d:\dev\SharpCompress\src\SharpCompress\Reader\AbstractReader.cs:line 137
   at SharpCompress.Reader.AbstractReader`2.MoveToNextEntry() in d:\dev\SharpCompress\src\SharpCompress\Reader\AbstractReader.cs:line 102
@AlexVallat commented on GitHub (Aug 12, 2016): Just in case, I might as well post the stack anyway now that I've captured it: ``` System.NotSupportedException: This stream does not support seek operations. at System.Net.ConnectStream.get_Position() at SharpCompress.IO.NonDisposingStream.get_Position() in d:\dev\SharpCompress\src\SharpCompress\IO\NonDisposingStream.cs:line 46 at SharpCompress.IO.RewindableStream.get_Position() in d:\dev\SharpCompress\src\SharpCompress\IO\RewindableStream.cs:line 97 at SharpCompress.Common.Zip.StreamingZipHeaderFactory.<ReadStreamHeader>d__0.MoveNext() in d:\dev\SharpCompress\src\SharpCompress\Common\Zip\StreamingZipHeaderFactory.cs:line 34 at SharpCompress.Reader.Zip.ZipReader.<GetEntries>d__0.MoveNext() in d:\dev\SharpCompress\src\SharpCompress\Reader\Zip\ZipReader.cs:line 46 at SharpCompress.Reader.AbstractReader`2.NextEntryForCurrentStream() in d:\dev\SharpCompress\src\SharpCompress\Reader\AbstractReader.cs:line 137 at SharpCompress.Reader.AbstractReader`2.MoveToNextEntry() in d:\dev\SharpCompress\src\SharpCompress\Reader\AbstractReader.cs:line 102 ```
Author
Owner

@AlexVallat commented on GitHub (Aug 12, 2016):

Thanks for the quick response!

@AlexVallat commented on GitHub (Aug 12, 2016): Thanks for the quick response!
Author
Owner

@adamhathcock commented on GitHub (Aug 12, 2016):

https://www.nuget.org/packages/sharpcompress/0.12.4

@adamhathcock commented on GitHub (Aug 12, 2016): https://www.nuget.org/packages/sharpcompress/0.12.4
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/sharpcompress#118