You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by "Igor Lubashev (JIRA)" <ji...@apache.org> on 2006/09/13 15:35:22 UTC

[jira] Commented: (HTTPCLIENT-598) ContentLengthInputStream does not implement available() properly

    [ http://issues.apache.org/jira/browse/HTTPCLIENT-598?page=comments#action_12434442 ] 
            
Igor Lubashev commented on HTTPCLIENT-598:
------------------------------------------

Oleg, I think this fix does not work.  The contract of available() is that it guarantees many bytes read() will return successfully and without blocking.

A better fix seems to be:

public int available() throws IOException
{
        if (closed)
              return 0;
        int avail = this.wrappedStream.available();
        if( pos + avail > contentLength )
            avail = contentLength - pos;
        return avail;
}

> ContentLengthInputStream does not implement available() properly
> ----------------------------------------------------------------
>
>                 Key: HTTPCLIENT-598
>                 URL: http://issues.apache.org/jira/browse/HTTPCLIENT-598
>             Project: HttpComponents HttpClient
>          Issue Type: Bug
>          Components: HttpClient
>    Affects Versions: 3.0.1, 3.1 Alpha 1
>            Reporter: Igor Lubashev
>             Fix For: 3.1 Beta 1
>
>         Attachments: 20060913-clis.patch
>
>
> ContentLengthInputStream should either extend FilterInputStream or should delegate available() to wrappedStream.
> Otherwise, available() on the response stream (an instance of AutoCloseInputStream, which is properly extending FilterInputStream, and, therefore, delegating to the ContentLengthInputStream) always returns 0.
> This issue is important for the clients that try to improve performance by processing all data that can be read in a non-blocking way before blocking on the network.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

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