title: HeadersTooLargeException - response headers
body: <p>I have implmented file download in my project in Spring mvc and while downloading the file it gives me below error on tomcat 7 server:</p>
  
  <pre><code>org.apache.coyote.http11.HeadersTooLargeException: 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.
  </code></pre>
  
  <p>I have also tried increasing the header size using below code in server.xml</p>
  
  <pre><code>&lt;Connector port="8080" maxHttpHeaderSize="65536" protocol="HTTP/1.1" ... /&gt;
  </code></pre>
  
  <p>However, this is also not working and I still get the above error.</p>
  
  <p>Below is the controller code for file download:</p>
  
  <pre><code>@RequestMapping(value = "/admin/file/download", method = RequestMethod.GET)
  public @ResponseBody ModelAndView download(HttpServletRequest request,
          HttpServletResponse response) throws Exception {
      int id = ServletRequestUtils.getRequiredIntParameter(request, "id");
      Files file = this.filesManager.find(id);
      response.setContentType(file.getType());
      response.setContentLength(file.getFile().length);       
      response.setHeader("Content-Disposition", "attachment; filename=\""+ file.getFilename() + "\"");
      FileCopyUtils.copy(file.getFile(), response.getOutputStream());     
      response.flushBuffer();     
      return null;
  
  }
  </code></pre>
  
  <p>The class Files stores the file information from database:</p>
  
  <pre><code>  public class Files {
       private int id;
       private String filename;    
       private String type;
       private byte[] file;
    }
  </code></pre>
  
  <p>I have also tried removing the below line but still gives the same error:</p>
  
  <pre><code>        response.setHeader("Content-Disposition",
   "attachment; filename=\""+ file.getFilename() + "\"");
  </code></pre>