Once bug 396226 lands, it shouldn't be difficult to add a way for a request handler be given semi-raw (mediated) access to the output stream for the connection, to allow writing arbitrary data through that connection. This would allow for fun like a request handler that abruptly closes the connection without writing any data, writing malformed HTTP responses, and the like. This isn't the full extent of what might be wanted -- in particular, for a request handler to be invoked the incoming request's head (and body, if any) must have been fully received -- but it's most of it, and it's not especially far afield of what a pluggable HTTP server might reasonably expose.
Created attachment 374314 [details] [diff] [review]
Getting all the corner cases correct was trickier than I expected but still relatively easy with bug 396226 fixed.
Comment on attachment 374314 [details] [diff] [review]
looks ok. I would think about making some named functions that test for these booleans rather repeating them.
The conditions aren't quite repeated enough, or in the same semantic manner, for me to be willing to add functions for them -- not to mention that I too had problems coming up with good names for them when I tried to do so.
Will port to 191 (should be trivial, the two are fully synced since bug 396226 was ported) once it's clear this went fine (no problems actually expected), in the interests of keeping the APIs the same for backports and security fix patches...
Bad me, I forgot to bump the interface ID in the patch; did so now. I also documented this functionality on this MDC page: