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/02 23:21:24 UTC

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

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


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

Posted by "Sebastiaan van Erk (JIRA)" <ji...@apache.org>.
    [ 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


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

Posted by "Oleg Kalnichevski (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HTTPCORE-157?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Oleg Kalnichevski resolved HTTPCORE-157.
----------------------------------------

       Resolution: Fixed
    Fix Version/s: 4.0-beta2

Fixed in SVN trunk. Please review.

Oleg

> 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


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

Posted by "Oleg Kalnichevski (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HTTPCORE-157?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12585951#action_12585951 ] 

Oleg Kalnichevski commented on HTTPCORE-157:
--------------------------------------------

Corrected.

Oleg

> 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