adamhathcock / sharpcompress

SharpCompress is a fully managed C# library to deal with many compression types and formats.
MIT License
2.29k stars 482 forks source link

HttpBaseStream Gzip extract - NotSupportedException #843

Open Ilanlido opened 6 months ago

Ilanlido commented 6 months ago

Hi, looks like when trying to decompress a gzip through httpStream it throws NotSupportedException on Position when setting EntryStartPosition. what is the purpose of settings this field? how can i mitigate the problem? Thanks!

System.NotSupportedException: Specified method is not supported.
   at System.Net.Http.HttpBaseStream.get_Position()
   at SharpCompress.IO.RewindableStream.get_Position()
   at SharpCompress.Common.GZip.GZipFilePart..ctor(Stream stream, ArchiveEncoding archiveEncoding)
   at SharpCompress.Common.GZip.GZipEntry.GetEntries(Stream stream, OptionsBase options)+MoveNext()

P.S i'd prefer to not save the file to disk and read it again as FileStream if possible If that's not possible which types require random access? i know that .tar.gz works perfectly fine through http for example, Thanks in advance!

adamhathcock commented 6 months ago

You'll have to show me how you're calling things.

GZipFilePart does check CanSeek but Rewindable is meant to buffer unbufferable streams so shouldn't be used here.

adamhathcock commented 6 months ago

Actually, I take that back, GZipFilePart has a usage of Position no matter seeking. That should be changed

Ilanlido commented 6 months ago

I'm not familiar with the internals of how Gzip works, but again, why do we need EntryStartPosition? isn't there only one entry always in .gz? maybe i can help :)

adamhathcock commented 6 months ago

you're right but I'm not sure why I'm doing that....I'd have to look and remember