samccone/infestor — pull request #7 by jenius (2014-05-20 19:36:21+00:00)
Title: Refactorz

So there's a lot going on in here. I think every single line of the library was modified actually. But this does seem to work and the tests are passing. The main motivation here is that `res.write` can be called multiple times with chunks (and is in both connect and express latest versions due to streaming), the current version doesn't support more than one call to `res.write` or it breaks the whole request.

While I meant this to be a small change, it ended up being a lot larger, since the concat of the full response and replacement had to be moved to `res.end`, but headers are already written there, so content-length couldn't be added. So we had to switch over to `transfer-encoding: chunked` to avoid `content-length` entirely, which means adding more overrides, etc. Bunch of notes and documentation in the commit :cactus: