hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "oliver z (JIRA)" <j...@apache.org>
Subject [jira] Issue Comment Edited: (HTTPCLIENT-1004) EofSensorInputStreams available() always returns 0
Date Thu, 30 Sep 2010 17:35:32 GMT

    [ https://issues.apache.org/jira/browse/HTTPCLIENT-1004?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12916550#action_12916550
] 

oliver  z edited comment on HTTPCLIENT-1004 at 9/30/10 1:35 PM:
----------------------------------------------------------------

i am using HtmlUnit 2.8. I replaced the old HttpClient/HttpCore/HttpMime jars with the new
one (4.1alpha2 and 4.1-beta2) and recompiled it. So i think HtmlUnit is using the new one,
not the 4.0 version.

I tried to cast the InputStream to ContentLengthInputStream but i still get

Exception in thread "Thread-28" java.lang.ClassCastException: org.apache.http.conn.EofSensorInputStream
cannot be cast to org.apache.http.impl.io.ContentLengthInputStream
        at myPlay.player.PlayThread$SongSlider.run(PlayThread.java:56)

I will take a closer look on this on the weekend.

edit: i just saw that htmlunit uses DefaultHttpClient, could this be somehow the problem?

      was (Author: olze84):
    i am using HtmlUnit 2.8. I replaced the old HttpClient/HttpCore/HttpMime jars with the
new one (4.1alpha2 and 4.1-beta2) and recompiled it. So i think HtmlUnit is using the new
one, not the 4.0 version.

I tried to cast the InputStream to ContentLengthInputStream but i still get

Exception in thread "Thread-28" java.lang.ClassCastException: org.apache.http.conn.EofSensorInputStream
cannot be cast to org.apache.http.impl.io.ContentLengthInputStream
        at myPlay.player.PlayThread$SongSlider.run(PlayThread.java:56)

I will take a closer look on this on the weekend.
  
> EofSensorInputStreams available() always returns 0
> --------------------------------------------------
>
>                 Key: HTTPCLIENT-1004
>                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-1004
>             Project: HttpComponents HttpClient
>          Issue Type: Bug
>          Components: HttpClient
>    Affects Versions: 4.1 Alpha2
>         Environment: win 7 x64, netbeans 6.9.1, jdk6_21
>            Reporter: oliver  z
>
> i just wrote a little mp3 audio player which retrieves a stream and plays it. 
> to make sure the user does not play further than the song has been stored into ram, i
thought i just use the available() method from the class EofSensorInputStream.
> But this method always returns 0 (normal http connection), casting to a ByteArrayInputStream
would be nice, but thats not working... so i took a look at the implementation of available():
> http://www.docjar.com/html/api/org/apache/http/conn/EofSensorInputStream.java.html
>   165       @Override
>   166       public int available() throws IOException {
>   167           int a = 0; // not -1
>   168   
>   169           if (isReadAllowed()) {
>   170               try {
>   171                   a = wrappedStream.available();
>   172                   // no checkEOF() here, available() can't trigger EOF
>   173               } catch (IOException ex) {
>   174                   checkAbort();
>   175                   throw ex;
>   176               }
>   177           }
>   178   
>   179           return a;
>   180       }
> wrappedStream is an InputStream, and InputStream says to available():
> The available method for class InputStream always returns 0. 
> This method should be overridden by subclasses. 
> Im not sure if this is a bug or a feature request
> Is there any other way how i can check how many bytes has been transfered into ram?

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