I have some code which both writes to the response directly (using res.write) and also pipes some data to the response (using otherStream.pipe(res). The problem is that for some reason this library keeps track of Buffers and strings separately:
As a result, there's no way to piece back together the data that was written. _getBuffer/_getChunks sends only the Buffers that were written and not the string content, and vice versa. There's no way to reconstruct the original order either, since Buffers and string writes could've been interleaved.
I have some code which both writes to the response directly (using
res.write
) and also pipes some data to the response (usingotherStream.pipe(res)
. The problem is that for some reason this library keeps track of Buffers and strings separately:https://github.com/eugef/node-mocks-http/blob/5ab3de26a80bdbab04a7161a23a3df7bbaacbd53/lib/mockResponse.js#L351-L366
As a result, there's no way to piece back together the data that was written. _getBuffer/_getChunks sends only the Buffers that were written and not the string content, and vice versa. There's no way to reconstruct the original order either, since Buffers and string writes could've been interleaved.