DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT <http://issues.apache.org/bugzilla/show_bug.cgi?id=26070>. ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND INSERTED IN THE BUG DATABASE.
http://issues.apache.org/bugzilla/show_bug.cgi?id=26070 [RFE] Allow streaming of POST methods via chunked transfer encoding. ------- Additional Comments From [EMAIL PROTECTED] 2004-03-09 14:49 ------- Ortwin, The whole point of buffering is to avoid tiny chunks. Here is Sun's code from BufferedOutputStream: public synchronized void write(byte b[], int off, int len) throws IOException { if (len >= buf.length) { /* If the request length exceeds the size of the output buffer, flush the output buffer and then write the data directly. In this way buffered streams will cascade harmlessly. */ flushBuffer(); out.write(b, off, len); return; } if (len > buf.length - count) { flushBuffer(); } System.arraycopy(b, off, buf, count, len); count += len; } Here are two conditions under which the patch behaves better (let's assume 2048 byte buffer): 1) Buffer has 5 bytes in it, and a request to write 2048 bytes is received. BufferedOutputStream would cause 2 chunks to be written, one of length 5, one 2048. The new ChunkedOutputStream would write a single chunk of size 2053. 2) Buffer has 5 bytes in it, and a request to write 2047 bytes is received. BufferedOutputStream would cause a 5 byte chunk and buffer the rest for later (which incurs an unnecessary System.arrayCopy). The new ChunkedOutputStream writes a 2052 byte chunk. Essentially, what you get from BufferedOutputStream is a crapshoot. It's anywhere from 1 to buf.length (or the size of the passed in request). A chunk of length 1 has 500% overhead. ChunkedOutputStream guarantees a minimum chunk size (except for the last chunk). I'll fix up the copyright and resubmit. Thanks Moh --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]