Skip to content

XZStream doesn't support non-seekable streams #936

@montoner0

Description

@montoner0

XZStream tries to get a position from a stream and this isn't supported for non-seekable streams.

A simple repro:

using System.Net.Http;
using SharpCompress.Compressors.Xz;

new XZStream(await new HttpClient()
    .GetStreamAsync("https://deb.debian.org/debian/dists/bookworm/main/binary-amd64/Packages.xz"))
        .ReadByte();

will throw

System.NotSupportedException: Specified method is not supported.
   at System.Net.Http.HttpBaseStream.get_Position()
   at SharpCompress.Compressors.Xz.XZBlock..ctor(Stream stream, CheckType checkType, Int32 checkSize)
   at SharpCompress.Compressors.Xz.XZStream.NextBlock()
   at SharpCompress.Compressors.Xz.XZStream.ReadBlocks(Byte[] buffer, Int32 offset, Int32 count)
   at SharpCompress.Compressors.Xz.XZStream.Read(Byte[] buffer, Int32 offset, Int32 count)
   at System.IO.Stream.ReadByte()
   at Program.<<Initialize>>d__0.MoveNext() in :line 5

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions