title: too many bytes written - HttpsURLConnection
body: <p>i have written an application which would test the performance of a servlet.
  the code that i have written works well with some requests.
  if i increase to more connections then some times i get "too many bytes written " exception.</p>
  
  <pre><code>int startRange = 0, endRange = 10000;
  HttpsURLConnection c = null;
  
  c = getHttpsConnection(URL);
  c.setDoInput(true);
  c.setDoOutput(true);
  c.setRequestProperty("Content-Length",(cotentLength+1));
  c.setFixedLengthStreamingMode(contentLength+1);
  c.setRequestProperty("Content-Type","appplication/zip");
  c.setRequestMethod("POST");
  c.setRequestProperty("Content-Range", "bytes "+startRange+"-"+endRange+"/"+filesize);
  
  OutputStream op = c.getOutputStream();
  </code></pre>
  
  <p>i compute the fixed chunk to send into <code>byte[] partBuf = new byte[contentLength+1];</code></p>
  
  <p>then </p>
  
  <pre><code>op.write(partBuf)
  String range = c.getHeaderField("Range");
  
  in.close();
  op.flush();
  op.close();
  </code></pre>
  
  <p>i dont get "too many bytes written error" upto certain requests sent, 
  too many requests sent gives me this error only sometimes .. 
  how do i handle this scenario?</p>
  
  <p>usually for testing, i spawn some requests varying from 10, 100, 500, 1000 .. which inturn hits a servlet that receives the data in chunks.</p>