You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Pau aff9d08cee client 2 years ago
src client 2 years ago
LICENSE client 2 years ago client 2 years ago
package.json client 2 years ago


Clone a Node.js HTTP response stream

Build Status Coverage Status npm npm

Returns a new stream and copies over all properties and methods from the original response giving you a complete duplicate.

This is useful in situations where you need to consume the response stream but also want to pass an unconsumed stream somewhere else to be consumed later.


npm install --save clone-response


const http = require('http');
const cloneResponse = require('clone-response');

http.get('', response => {
  const clonedResponse = cloneResponse(response);

  setImmediate(() => {
    // The response stream has already been consumed by the time this executes,
    // however the cloned response stream is still available.

Please bear in mind that the process of cloning a stream consumes it. However, you can consume a stream multiple times in the same tick, therefore allowing you to create multiple clones. e.g:

const clone1 = cloneResponse(response);
const clone2 = cloneResponse(response);
// response can still be consumed in this tick but cannot be consumed if passed
// into any async callbacks. clone1 and clone2 can be passed around and be
// consumed in the future.



Returns a clone of the passed in response.


Type: stream

A Node.js HTTP response stream to clone.


MIT © Luke Childs