You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by "Sebastiaan van Erk (JIRA)" <ji...@apache.org> on 2008/04/04 23:56:31 UTC

[jira] Commented: (HTTPCORE-157) flush() in ChunkedOutputStream does not follow the spec of OutputStream#flush()

    [ https://issues.apache.org/jira/browse/HTTPCORE-157?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12585796#action_12585796 ] 

Sebastiaan van Erk commented on HTTPCORE-157:
---------------------------------------------

Looks good, one small comment, the javadoc of the class still describes the old behavior:

 * Chunks are guaranteed to be at least as large as the buffer size (except for the last chunk).

> 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
>             Fix For: 4.0-beta2
>
>
> 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