--- container/catalina/src/share/org/apache/catalina/connector/OutputBuffer.java (revision 747981) +++ container/catalina/src/share/org/apache/catalina/connector/OutputBuffer.java (working copy) @@ -79,6 +79,7 @@ * State of the output buffer. */ private int state = 0; + private boolean initial = true; /** @@ -229,6 +230,7 @@ public void recycle() { state = INITIAL_STATE; + initial = true; bytesWritten = 0; charsWritten = 0; @@ -306,15 +308,17 @@ return; doFlush = true; + if (initial) { + // If the buffers are empty, commit the response header + coyoteResponse.sendHeaders(); + initial = false; + } if (state == CHAR_STATE) { cb.flushBuffer(); bb.flushBuffer(); state = BYTE_STATE; } else if (state == BYTE_STATE) { bb.flushBuffer(); - } else if (state == INITIAL_STATE) { - // If the buffers are empty, commit the response header - coyoteResponse.sendHeaders(); } doFlush = false; @@ -650,6 +654,7 @@ gotEnc = false; enc = null; state = INITIAL_STATE; + initial = true; }