|Summary:||Ignoring setContentLength( ) when using writer is incomplete|
|Product:||Tomcat 7||Reporter:||Konstantin Kolinko <knst.kolinko>|
|Component:||Catalina||Assignee:||Tomcat Developers Mailing List <dev>|
Description Konstantin Kolinko 2011-02-09 16:48:03 UTC
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.
Comment 1 Mark Thomas 2011-02-09 17:19:52 UTC
*** Bug 50747 has been marked as a duplicate of this bug. ***
Comment 2 Mark Thomas 2011-02-09 17:40:44 UTC
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.