https://issues.apache.org/bugzilla/show_bug.cgi?id=57347
Bug ID: 57347 Summary: AJP response contains wrong status reason phrase Product: Tomcat 8 Version: trunk Hardware: All OS: All Status: NEW Severity: normal Priority: P2 Component: Connectors Assignee: dev@tomcat.apache.org Reporter: rainer.j...@kippdata.de This problem applies to TC 8 and 9: I get AJP responses with status code 200 but wrong reason phrase "ACT" instead of "OK". The problem is due to the MessageBytes tmpMB being used in AbstractAjpProcessor first in prepareResponse() for processing the request, then in prepareResponse() for setting the reason phrase. During prepareRequest() only the byte (ByteChunk) functionality of tmpMB is used, during prepareResponse() the String functionality. Now appending the reason phrase to the AJP message is done using AjpMessage.appendBytes(). This function has changed between TC 7 and TC 8 to support multiple charsets (r1630910). In TC 7 when the MessageBytes is of type T_STR, which is the case here, the append does: appendString(mb.toString()); After the change in TC 8 it calls mb.toBytes(); and then uses the ByteChunk in mb. The implementation of mb.toBytes() checks, whether the ByteChunk already set before (isSet) and then doesn't do the string to ByteChunk conversion. Since the MessageBytes tmpMB was used before to read request headers and attributes, it already has a ByteChunk set, so the conversion is skipped and the old value of the ByteChunk is used. As a result the value of the last part read from the request - in my case the string "ACT" is appended as the status reason phrase. I suggest to not change the behavior in AjpMessage.appendBytes() but instead recycle the tmpMB MessageBytes before using it in AjpProcessor.prepareResponse() (TC 9) resp. AbstractAjpProcessor.prepareResponse() (TC 8). --- java/org/apache/coyote/ajp/AjpProcessor.java (revision 1645245) +++ java/org/apache/coyote/ajp/AjpProcessor.java (working copy) @@ -1388,6 +1388,7 @@ response.setCommitted(true); + tmpMB.recycle(); responseMsgPos = -1; responseMessage.reset(); responseMessage.appendByte(Constants.JK_AJP13_SEND_HEADERS); Regards, Rainer -- You are receiving this mail because: You are the assignee for the bug. --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org