Skip to content

Non-blocking mechanism to transform request/response body streams #192

@pimterry

Description

@pimterry

Hi @avarayr, I saw you left a comment on a PR (#145, comment now removed?) relating to this, so I thought I'd file a proper issue to track the suggestion.

I can definitely see use cases for transforming streams of content, and I'm open to ideas. This is indeed not supported by the current APIs, which instead block for the body before running the callbacks every time. The PR you commented on isn't really related to this as such, but it's part of a general improvement in support for streaming overall.

Do you have any thoughts on how you'd like this to work? If you can share more information about the kind of transform you're interested in that would be useful.

A relatively simple option would be to add a new kind of RequestTransform/ResponseTransform option, for declarative transformations instead of a callback, but whether that's possible depends on the kinds of transform you'd be doing.

Alternatively, there are certainly ways to modify the existing callback approach to support this, it's just a question of tradeoffs. I'm currently in the process of preparing some big changes for Mockttp v4 though, so if there are breaking changes required for this then now is the time to make them.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions