Hi, I currently am developing a Cloudflare Edge Worker script that evaluates a series of instructions to modify a page’s HTML body. I was reading about the Streams API that can be used in workers, and the text following the example mentions “This example just pumps the subrequest response body to the final response body; however, you can use more complicated logic, such as adding a prefix or a suffix to the body or to process it somehow.”.
I was wondering: Is it possible to modify the HTML body while using Streams? If the content is being modified in chunks, then what happens if the HTML element that is being modified is split between two chunks? Would the appropriate approach to take in that case to be buffering the chunks to handle that case?
Any tips or examples would be appreciated. Thank you!