title: Removing Content-Disposition causes ClientAbortException: java.net.SocketException: socket write error: Connection aborted by peer
body: <p>My application servers .wav files, which are downloadable at certain URLs. I have to change the logic so that they will be streamed instead of being downloaded - so I will remove Content-Disposition header that was being explicitly set.</p>
  
  <p>Piece of code:</p>
  
  <pre><code>// removed    
  //response.setHeader("Content-Disposition", "attachment;filename=" + fileName);
  
  bis = new BufferedInputStream(inputStream);
  bos = new BufferedOutputStream(sOutputStream);
  
  byte[] buff = new byte[10000];
  int bytesRead = 0;
  while(-1 != (bytesRead = bis.read(buff))) {
      bos.write(buff, 0, bytesRead);
  }
  bos.flush();
  </code></pre>
  
  <p>2nd or 3rd call to <code>bos.write</code> causes</p>
  
  <pre><code>ClientAbortException: java.net.SocketException: socket write error: Connection aborted by peer 
      at org.apache.catalina.connector.OutputBuffer.realWriteBytes(OutputBuffer.java:402)
      at org.apache.tomcat.util.buf.ByteChunk.flushBuffer(ByteChunk.java:449) 
      at org.apache.tomcat.util.buf.ByteChunk.append(ByteChunk.java:349) 
      at org.apache.catalina.connector.OutputBuffer.writeBytes(OutputBuffer.java:425) 
      at org.apache.catalina.connector.OutputBuffer.write(OutputBuffer.java:414) 
      at org.apache.catalina.connector.CoyoteOutputStream.write(CoyoteOutputStream.java:89) 
      at java.io.BufferedOutputStream.write(BufferedOutputStream.java:105) 
  </code></pre>
  
  <p>When I debug the code, at the time write method fails, the browser opens a player and another, identical request is being generated and succeeds.</p>
  
  <p>When Content-Disposition is set eveything works fine. Any ideas?</p>