Skip to content

BZip2AsyncOutputStream #877

Open
Open
@logiclrd

Description

@logiclrd

Is your feature request related to a problem? Please describe.

I want to stream BZip2-compressed data from a result handler in an ASP.NET Core web app. The ASP.NET Core response stream only supports async operations. I found that BZip2OutputStream is inherently synchronous, so I copied it into my project and created BZip2AsyncOutputStream by means of straightforwardly replacing all calls to synchronously output bytes with async calls instead. A couple of cases required async-over-sync (explicit .Wait), since e.g. disposing the stream results in synchronous .Write and .Flush calls, but in the main operation it's all async. It seems to work. No idea on the impact on efficiency.

Would there be any interest in a contribution of this class?

Describe the solution you'd like

I'd like to make a PR that adds BZip2AsyncOutputStream to SharpZipLib so that other people who, like me, want to stream BZip2-compressed data in contexts that don't support synchronous I/O have an option. But I don't want to make a PR if it is unwelcome. :-)

Describe alternatives you've considered

There aren't really any alternatives, as I understand it. Async code simply requires you to be async up and down the call stack.

Tags

BZip2

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bzip2enhancementFeature request or other improvements of existing functionality

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions