Skip to content

Feature request: Allow response streams to be piped manually #143

Open
@rageshkrishna

Description

@rageshkrishna

I have a need to grab the passthrough server response stream and write it to a file. The goal is to be able to save matching responses to a file while also streaming it back to the client without adding any delays.

I'd like to propose supporting a new property in PassThroughHandlerOptions to enable this feature. Something like this:

server.forAnyRequest().thenPassThrough({
  onStreaming: (serverRes, clientRes, reqUrl) => {
    // The user _has_ to do this as a minimum. Maybe we could
    // be smarter about this and handle it in the request-handler
    // based on a return value from this callback.
    serverRes.pipe(clientRes);
  }
});

I'm completely new to this project and just starting to understand how the APIs are structured, so please let me know if this violates any of your design principles and if so, I'd appreciate some feedback on how to better design this. The property name and parameters are, of course, open to discussion. This is just something I prototyped in a few minutes to achieve my goal. If there's interest in enabling this feature, I'd be happy to work on a PR.

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