Is there a way to hook a progress bar to an HTTP download? I'm trying to make an installer for Squellenium and when it downloads the zip the long pause is disconcerting. Here's how I'm downloading:
downloadSelenium ^ ZipArchive new readFrom: (self seleniumZipURI retrieveContents contentStream binary; yourself)
So I send retrieveContents to a HttpURL. I did a cursory hunt through the image but couldn't turn up anything (I did find lots of progress bar examples but nothing connected with HTTP).
David
I think you could change the following method in HTTPSocket to get a progress display of any HTTP download.
getRestOfBuffer: beginning totalLength: length ... 'Downloading' displayProgressAt: Display center from: 0 to: length during: [:bar| [(response position < length) & (self isConnected | self dataAvailable)] whileTrue: [ bar value: response position. (self waitForDataUntil: (Socket deadlineSecs: 5)) ifFalse: [ ...
David Shaffer schrieb:
Is there a way to hook a progress bar to an HTTP download? I'm trying to make an installer for Squellenium and when it downloads the zip the long pause is disconcerting. Here's how I'm downloading:
downloadSelenium ^ ZipArchive new readFrom: (self seleniumZipURI retrieveContents contentStream binary; yourself)
So I send retrieveContents to a HttpURL. I did a cursory hunt through the image but couldn't turn up anything (I did find lots of progress bar examples but nothing connected with HTTP).
David
Alexander Lazarević wrote:
I think you could change the following method in HTTPSocket to get a progress display of any HTTP download.
getRestOfBuffer: beginning totalLength: length ... 'Downloading' displayProgressAt: Display center from: 0 to: length during: [:bar| [(response position < length) & (self isConnected | self dataAvailable)] whileTrue: [ bar value: response position. (self waitForDataUntil: (Socket deadlineSecs: 5)) ifFalse: [ ...
Thanks!
David
Maybe it is also good to notice, that the method allocates a String Buffer of file size length before starting to download. Depending on the file size, your RAM and maybe vm memory settings, this could also lead to a (very) long pause. So as an example the following might work on your machine, but on mine the download never starts! :}
'http://debian.uni-essen.de/debian-cd/3.1_r0a/i386/iso-cd/debian-31r0a-i386-b...' asUrl retrieveContents
Alex
David Shaffer schrieb:
Alexander Lazarević wrote:
I think you could change the following method in HTTPSocket to get a progress display of any HTTP download.
getRestOfBuffer: beginning totalLength: length ... 'Downloading' displayProgressAt: Display center from: 0 to: length during: [:bar| [(response position < length) & (self isConnected | self dataAvailable)] whileTrue: [ bar value: response position. (self waitForDataUntil: (Socket deadlineSecs: 5)) ifFalse: [ ...
Thanks!
David
squeak-dev@lists.squeakfoundation.org