title: ServletResponse.setBufferSize doesn't work in Tomcat 7?
body: <p>I'm increasing the buffer size of a response using ServletResponse.setBufferSize but Tomcat 7 is still throwing an exception that the buffer size is not big enough.  Is this a bug in Tomcat 7.0.32?</p>
  
  <p>Here is my pseudo/code -</p>
  
  <pre><code>@Override
  protected void writeInternal(Object o, HttpOutputMessage outputMessage)
      throws IOException, HttpMessageNotWritableException {
  
      if (some condition)
      {
          ((ServletServerHttpResponse)outputMessage).getServletResponse().setBufferSize(Integer.MAX_VALUE);
          outputMessage.getHeaders().set("Custom-Header", gson.toJson(big payload));
      }
  
      // ...
  </code></pre>
  
  <p>This is the exception -</p>
  
  <p><code>org.apache.coyote.http11.HeadersTooLargeException</code>: An attempt was made to write more data to the response headers than there was room available in the buffer. Increase maxHttpHeaderSize on the connector or write less data into the response headers.</p>
  
  <p>Do I need to reset the buffer?  <code>reset()</code> did not work.</p>
  
  <p>EDIT: I'm looking for the ability to change the maximum header size at the individual response level based upon "some condition".</p>