Return-Path: Delivered-To: apmail-hc-dev-archive@www.apache.org Received: (qmail 84929 invoked from network); 1 Oct 2010 05:51:57 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 1 Oct 2010 05:51:57 -0000 Received: (qmail 15903 invoked by uid 500); 1 Oct 2010 05:51:57 -0000 Delivered-To: apmail-hc-dev-archive@hc.apache.org Received: (qmail 15706 invoked by uid 500); 1 Oct 2010 05:51:55 -0000 Mailing-List: contact dev-help@hc.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "HttpComponents Project" Delivered-To: mailing list dev@hc.apache.org Received: (qmail 15698 invoked by uid 99); 1 Oct 2010 05:51:54 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 01 Oct 2010 05:51:54 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.22] (HELO thor.apache.org) (140.211.11.22) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 01 Oct 2010 05:51:54 +0000 Received: from thor (localhost [127.0.0.1]) by thor.apache.org (8.13.8+Sun/8.13.8) with ESMTP id o915pXUd014028 for ; Fri, 1 Oct 2010 05:51:33 GMT Message-ID: <5839475.492421285912293547.JavaMail.jira@thor> Date: Fri, 1 Oct 2010 01:51:33 -0400 (EDT) From: "oliver z (JIRA)" To: dev@hc.apache.org Subject: [jira] Issue Comment Edited: (HTTPCLIENT-1004) EofSensorInputStreams available() always returns 0 In-Reply-To: <10583262.467831285790493424.JavaMail.jira@thor> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/HTTPCLIENT-1004?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12916790#action_12916790 ] oliver z edited comment on HTTPCLIENT-1004 at 10/1/10 1:51 AM: ---------------------------------------------------------------- i tested it with a free online mp3: HttpClient httpclient = new DefaultHttpClient(); HttpGet httpget = new HttpGet("http://www.ravn.de/stuff/Programmierer.mp3"); HttpResponse response = httpclient.execute(httpget); HttpEntity entity = response.getEntity(); if (entity != null) { InputStream instream = entity.getContent(); try { while (instream.read() != -1) { System.out.println(instream.available()); } } finally { instream.close(); } } looks pretty strange to me, because if the read() method is not there (eg. while(true)) the output is always 1451 and the count is not rising i'm not sure why in my application the output is always 0... any ideas? was (Author: olze84): i tested it with a free online mp3: HttpClient httpclient = new DefaultHttpClient(); HttpGet httpget = new HttpGet("http://www.ravn.de/stuff/Programmierer.mp3"); HttpResponse response = httpclient.execute(httpget); HttpEntity entity = response.getEntity(); if (entity != null) { InputStream instream = entity.getContent(); try { while (instream.read() != -1) { System.out.println(instream.available()); } } finally { instream.close(); } } looks pretty strange to me i'm not sure why in my application the output is always 0... any ideas? > 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