Return-Path: Delivered-To: apmail-jakarta-httpclient-dev-archive@www.apache.org Received: (qmail 93354 invoked from network); 16 Nov 2004 15:01:52 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 16 Nov 2004 15:01:52 -0000 Received: (qmail 28064 invoked by uid 500); 16 Nov 2004 15:01:50 -0000 Delivered-To: apmail-jakarta-httpclient-dev-archive@jakarta.apache.org Received: (qmail 28029 invoked by uid 500); 16 Nov 2004 15:01:50 -0000 Mailing-List: contact httpclient-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "HttpClient Project" Reply-To: "HttpClient Project" Delivered-To: mailing list httpclient-dev@jakarta.apache.org Received: (qmail 28007 invoked by uid 99); 16 Nov 2004 15:01:50 -0000 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: neutral (hermes.apache.org: local policy) Received: from [195.186.4.73] (HELO mail2.bluewin.ch) (195.186.4.73) by apache.org (qpsmtpd/0.28) with ESMTP; Tue, 16 Nov 2004 07:01:47 -0800 Received: from xbox.localdomain (62.202.83.224) by mail2.bluewin.ch (Bluewin AG 7.0.031.3) id 41888440001385A0 for httpclient-dev@jakarta.apache.org; Tue, 16 Nov 2004 15:01:42 +0000 Received: by xbox.localdomain (Postfix, from userid 1000) id C27E9B6ECB; Tue, 16 Nov 2004 16:01:45 +0100 (CET) Date: Tue, 16 Nov 2004 16:01:45 +0100 From: Oleg Kalnichevski To: HttpClient Project Subject: Re: How i can get information about the downloading process? Message-ID: <20041116150145.GA27304@xbox.localdomain> Mail-Followup-To: HttpClient Project References: <00a101c4cb93$0db65260$ae7c2cd4@javaworld> <00c801c4cbb0$2e055300$ae7c2cd4@javaworld> <20041116090007.GB27001@xbox.localdomain> <00f101c4cc02$f223cd50$ae7c2cd4@javaworld> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <00f101c4cc02$f223cd50$ae7c2cd4@javaworld> User-Agent: Mutt/1.4.2.1i X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N On Tue, Nov 16, 2004 at 09:37:21AM -0800, Gaspar wrote: > Hi Oleg, > > Yes i know that i can get the Response body with getResponseBodyAsStream, > but i need that this line > > statusCode = client.executeMethod(method); > > finish the download process, for example if the file is 3MB over a 28Kb/s it > can took 20mintutes, then 20minutes later i can do this: Gaspar, The whole point is that HttpClient#executeMethod method does NOT retrieve the response content. This method executes the request, reads the status line and response headers, makes sure that the response looks sane and then terminates. At this point it is up to you what you do with the response body. You can get it as one big chunk with HttpMethod#getResponseBody or HttpMethod#getResponseBodyAsString, or as a stream with HttpMethod#getResponseBodyAsStream and read the content out in smaller chunks as you see fit Hope this clarifies things a little Oleg > > responseBody = method.getResponseBodyAsStream(); > > but i don't need this, i must read the amount of bytes on the buffer each 1 > second that let me calculate that Chris describe, > > * the total number of bytes so far read (must be do each second to update > the info) > * determine the average speed so far by dividing the number of bytes > downloaded by the time taken so far (must be do each second to update the > info) > > resuming: that i need is take control over the download process each 1 > seconds or less accessing the buffer that hold the bytes doanload so far to > see how many bytes is download each 1seconds to update this info in the GUI, > etc... maybe some code can help me. > > do you understand me?, please maybe i don't get the point, sorry be patience > :-), and very thanks! for the attention of the all community! > > Thanks, > Gaspar > > ----- Original Message ----- > From: "Oleg Kalnichevski" > To: "HttpClient Project" > Sent: Tuesday, November 16, 2004 1:00 AM > Subject: Re: How i can get information about the downloading process? > > > > On Mon, 2004-11-15 at 23:30 -0800, Gaspar wrote: > > > Hi Mike, > > > > > > Yes but i think that with the Response body only i can't know "How > > > many > > > bytes is downloaded already?". > > > > > > > Gaspar, > > This is actually quite trivial. Just use > > HttpMethod#getResponseBodyAsStream and you'll have a complete control > > over the response retrieval process. > > > > > > > My question, Is possible to built-in this > > > feature in the future? or is imposible due to HttpClient use only Java > > > Sync > > > IO?. > > > > > > > There's already a request for this feature. I'll be addressed in the > > next major release of HttpClient (that is, 4.0): > > > > http://issues.apache.org/bugzilla/show_bug.cgi?id=10815 > > > > Hope this helps > > > > Oleg > > > > > > > > ----- Original Message ----- > > > From: "Michael Becke" > > > To: "HttpClient Project" > > > Sent: Monday, November 15, 2004 8:06 PM > > > Subject: Re: How i can get information about the downloading process? > > > > > > > > > Hi Gaspar, > > > > > > HttpClient does not support timing directly. There is no built-in way > > > to get status on the request progress. As Chris has described the only > > > real timing that can be done is with the response body. > > > > > > Mike > > > > > > On Nov 15, 2004, at 11:14 PM, Gaspar wrote: > > > > > > > Hi Chris, > > > > > > > > First of all, thanks for your explanation, but maybe i don't explain > > > > very > > > > well what is my problem. Yes i know that this is the way to obtain > this > > > > information, but how you can did the algorithm that you describe if > > > > the code > > > > line (see below the number 1) don't return until it finish the > download > > > > process completely. do you understand now my doubt?. Maybe using > > > > multithreading i can resolve this problem, but can i only resolve it > > > > using > > > > multithreading only? > > > > > > > > thanks in advance, > > > > Gaspar > > > > > > > > Here is the code, see the line 1), is what i use to download the file. > > > > ... > > > > > > > > HttpMethod method = new GetMethod(getURL().toString()); > > > > > > > > ... > > > > > > > > // start the download process > > > > line 1) statusCode = client.executeMethod(method); > > > > ----- Original Message ----- > > > > From: "Chris Brown" > > > > To: > > > > Sent: Sunday, November 07, 2004 1:00 AM > > > > Subject: RE: How i can get information about the downloading process? > > > > > > > > > > > >> Hi Gaspar, > > > >> > > > >> If you use some of the approaches that let HTTPClient do all the hard > > > >> work > > > >> for you, you'll not have this feedback as far as I'm aware. > > > >> > > > >> But it's quite simple to get this information yourself. If you open > > > >> the > > > >> connection and read data as a stream, you need to remember : > > > >> > > > >> * the time (e.g. System.currentTimeMillis()) you started as a "long" > > > >> variable > > > >> > > > >> * the total number of bytes so far read as a "long" variable, updated > > > >> each > > > >> time you read some bytes from the stream > > > >> > > > >> * you can determine the average speed so far by dividing the number > of > > > > bytes > > > >> downloaded by the time taken so far (see both points above); that's > > > >> not > > > >> necessarily your current speed > > > >> > > > >> * for the percentage remaining, you'll need to know in advance the > > > >> size of > > > >> what you're going to download (the HTTP response header > > > >> "Content-Length" > > > >> should help here, but you're not always going to get this > > > >> information, and > > > >> it's not always provided correctly by the server). > > > >> > > > >> You'll want multithreading no doubt, so make your "download" object > > > >> expose > > > > > > > >> this information through "getter" methods. You can then display this > > > >> on > > > > the > > > >> command line, in a progress bar, or whatever. > > > >> > > > >> - Chris > > > >> > > > >> > > > >>> From: "Gaspar" > > > >>> Reply-To: "HttpClient Project" > > > >>> To: > > > >>> Subject: How i can get information about the downloading process? > > > >>> Date: Sat, 6 Nov 2004 16:08:35 -0800 > > > >>> > > > >>> Hi, > > > >>> > > > >>> My question is about how i can do with HttpClient, something that i > > > >>> see > > > > on > > > >>> many download manager software. > > > >>> > > > >>> About the file that i'm downloading using HttpClient i want to get > > > >>> this > > > >>> information: > > > >>> > > > >>> - % of the file that is downloaded already. > > > >>> - the size of what is downloaded already. > > > >>> - the speed rate(b/s) of what is downloading. > > > >>> - the time left to finish the download process. > > > >>> > > > >>> the downlaod manager that i use is ReGet Deluxe 3.3 and i want do > > > > something > > > >>> similar with HttpClient. > > > >>> > > > >>> Thanks in advance, > > > >>> Gaspar > > > >>> > > > >>> > > > >>> > > > >>> > > > > >>> --------------------------------------------------------------------- > > > >>> To unsubscribe, e-mail: > httpclient-dev-unsubscribe@jakarta.apache.org > > > >>> For additional commands, e-mail: > > > >>> httpclient-dev-help@jakarta.apache.org > > > >>> > > > >> > > > >> _________________________________________________________________ > > > >> MSN Actions Solidaires : volontaire ? l'?tranger > > > >> http://www.msn.fr/actionssolidaires/Default.asp?Ath=f > > > >> > > > >> > > > >> --------------------------------------------------------------------- > > > >> To unsubscribe, e-mail: httpclient-dev-unsubscribe@jakarta.apache.org > > > >> For additional commands, e-mail: > > > >> httpclient-dev-help@jakarta.apache.org > > > >> > > > > > > > > > > > > > > > > --------------------------------------------------------------------- > > > > To unsubscribe, e-mail: httpclient-dev-unsubscribe@jakarta.apache.org > > > > For additional commands, e-mail: > httpclient-dev-help@jakarta.apache.org > > > > > > > > > > > > > --------------------------------------------------------------------- > > > To unsubscribe, e-mail: httpclient-dev-unsubscribe@jakarta.apache.org > > > For additional commands, e-mail: httpclient-dev-help@jakarta.apache.org > > > > > > > > > > > > --------------------------------------------------------------------- > > > To unsubscribe, e-mail: httpclient-dev-unsubscribe@jakarta.apache.org > > > For additional commands, e-mail: httpclient-dev-help@jakarta.apache.org > > > > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: httpclient-dev-unsubscribe@jakarta.apache.org > > For additional commands, e-mail: httpclient-dev-help@jakarta.apache.org > > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: httpclient-dev-unsubscribe@jakarta.apache.org > For additional commands, e-mail: httpclient-dev-help@jakarta.apache.org > --------------------------------------------------------------------- To unsubscribe, e-mail: httpclient-dev-unsubscribe@jakarta.apache.org For additional commands, e-mail: httpclient-dev-help@jakarta.apache.org