Uploaded image for project: 'HttpComponents HttpCore'
  1. HttpComponents HttpCore
  2. HTTPCORE-157

flush() in ChunkedOutputStream does not follow the spec of OutputStream#flush()

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 4.0-beta2
    • 4.0-beta2
    • HttpCore
    • None

    Description

      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).

      Attachments

        Activity

          People

            Unassigned Unassigned
            sebster Sebastiaan van Erk
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: