Return-Path: Delivered-To: apmail-jakarta-commons-httpclient-dev-archive@www.apache.org Received: (qmail 13806 invoked from network); 9 Mar 2004 14:49:20 -0000 Received: from daedalus.apache.org (HELO mail.apache.org) (208.185.179.12) by minotaur-2.apache.org with SMTP; 9 Mar 2004 14:49:20 -0000 Received: (qmail 67369 invoked by uid 500); 9 Mar 2004 14:49:15 -0000 Delivered-To: apmail-jakarta-commons-httpclient-dev-archive@jakarta.apache.org Received: (qmail 67352 invoked by uid 500); 9 Mar 2004 14:49:15 -0000 Mailing-List: contact commons-httpclient-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Commons HttpClient Project" Reply-To: "Commons HttpClient Project" Delivered-To: mailing list commons-httpclient-dev@jakarta.apache.org Received: (qmail 67338 invoked from network); 9 Mar 2004 14:49:15 -0000 Received: from unknown (HELO exchange.sun.com) (192.18.33.10) by daedalus.apache.org with SMTP; 9 Mar 2004 14:49:15 -0000 Received: (qmail 25417 invoked by uid 50); 9 Mar 2004 14:49:46 -0000 Date: 9 Mar 2004 14:49:46 -0000 Message-ID: <20040309144946.25416.qmail@nagoya.betaversion.org> From: bugzilla@apache.org To: commons-httpclient-dev@jakarta.apache.org Cc: Subject: DO NOT REPLY [Bug 26070] - [RFE] Allow streaming of POST methods via chunked transfer encoding. X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT . 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 mohammad.rezaei@gs.com 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: commons-httpclient-dev-unsubscribe@jakarta.apache.org For additional commands, e-mail: commons-httpclient-dev-help@jakarta.apache.org