bugfix: we did not set r->header_sent when we want to discard the header in our header filter.
bugfix: we might (incorrectly) return 500 in our output filters. bugfix: we should return NGX_ERROR in case of memory allocation errors.