Reviewing o.a.c.connector.Response after comments in https://issues.apache.org/bugzilla/show_bug.cgi?id=50747#c3 In o.a.c.connector.Response there is a feature that Response#setContentLength(int) ignores the call if usingWriter flag is true. My comments are: 1) It concerns only multi-byte charsets such as UTF-8. There is nothing wrong with calling setContentLength() if it is a single-byte charset. 2) There is no such protection in Response#setHeader(), #setIntHeader(), #addHeader(), #addIntHeader() methods. Calling them will bypass the protection. See how o.a.coyote.Response implements those methods and o.a.coyote.Response#checkSpecialHeader() for comparison.
*** Bug 50747 has been marked as a duplicate of this bug. ***
This fixed in 7.0.x and will be included in 7.0.9 onwards. Both single and multi-byte encodings are handled since OutputBuffer.close() sets the content-length to the number of bytes, not the number of characters. I suspect the test in the response dates from a time when content length was set using characters although I haven't done the code archeology to be sure of that.