adamhathcock/sharpcompress

NotSupportedException for forward-only reading of unseekable ConnectStream

AlexVallat opened this issue · 5 comments

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.

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

Never mind, I reproduced it.

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

Thanks for the quick response!