hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sebastiaan van Erk (JIRA)" <j...@apache.org>
Subject [jira] Created: (HTTPCORE-157) flush() in ChunkedOutputStream does not follow the spec of OutputStream#flush()
Date Wed, 02 Apr 2008 21:21:24 GMT
flush() in ChunkedOutputStream does not follow the spec of OutputStream#flush()
-------------------------------------------------------------------------------

                 Key: HTTPCORE-157
                 URL: https://issues.apache.org/jira/browse/HTTPCORE-157
             Project: HttpComponents HttpCore
          Issue Type: Bug
          Components: HttpCore
    Affects Versions: 4.0-beta2
            Reporter: Sebastiaan van Erk
            Priority: Minor


One of the nice things about chunked encoding is that you can send your data in little parts.


However, flush() on ChunkedOutputStream does not flush the buffer:
 
     /**
      * Flushes the underlying stream, but leaves the internal buffer alone.
      * @throws IOException
      */
     public void flush() throws IOException {
         this.out.flush();
     }

This is kind of against the spec of flush on OutputStream:
 
     /**
      * Flushes this output stream and forces any buffered output bytes
      * to be written out. The general contract of <code>flush</code> is
      * that calling it is an indication that, if any bytes previously
      * written have been buffered by the implementation of the output
      * stream, such bytes should immediately be written to their
      * intended destination.
      * ...

Generally if a client does not want to flush the data they won't call flush, which will cause
all the chunks to attain the full chunk  size anyway...

The fix would be to add a flushCache() call right before this.out.flush(). Currently I'm using
my own subclass of ChunkedOutputStream which does exactly this and it works perfectly; the
chunks in my application have the full size 99% of the time (unless I explicitly flush in
the writeTo(OutputStream) method of my Entity).

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


Mime
View raw message