Overriding `Request.write` like this is not the way to go. Even though you (now) only use it in a very specific way, in regular use `write` can be called more than once, and setting the header there is the wrong place. Better make a (private) helper function to do the same thing, e.g. `_writeBody`. You can also have it call `finish` if you want.