Hi Pekr

source read-net
"open url"
    set-modes port/sub-port [lines: false binary: true no-wait: true] 

seems open http:// goes to wait-mode to get the header.
after that is done one can set-mode[no-wait: true].

-Volker

Am Freitag, 16. August 2002 07:57 schrieb Petr Krenzelok:
> Hello,
>
> in the age of advanced Internet browsers, we still can meet with very
> lame downloaders they provide. They offer no ability to start at the
> place where download was broken. So I created following 1KB in size
> small util. As you can see - no GUI. I tried, but I spent most of my
> time playing with look, so I gave up. It is simple, small, does what it
> is supposed to do, well, mostly.
>
> Every time I think I finally understand how something works, I stay
> starving at console, getting unexpected results. So, the script as it is
> seems to work. Just try to answer my following questions:
>
> 1) I tried to use simply "data: copy source" aproach. The strange thing
> is, that while I use /no-wait, it should perform body block of 'while.
> But I can see console hanging, and the body block is entered only once -
> once file is completly downloaded. But - 'copy should not block here, no?
>
> 2) With larger file, I obtain network time-out. So I tried to use some
> kind of "not error? try [data: copy source]", but well, once port is
> closed by the other side, 'none is generated, but 'none itself doesn't
> return false(error) state to 'try. So - how to adapt the script, so I
> could safely go home, and let my script to
> download-damned-thing-even-in-million-pieces, safely? :-)
>
> ... I turned it back to copy/part aproach, but - is open/no-wait on http
> port broken? Why does 'copy block, or - what happens at all? Any
> explanation appreciated.
>
> PS: used write/binary/append, untill open/skip works as expected ....
>
> -pekr-
>
> -------------------------------
> REBOL []
>
> source-url: http://www.rebol.cz/~cyphre/
> source-file: %styles2.jpg
>
> target-path: %./
> target-file: source-file
>
> source-size: size? join source-url source-file
>
> either exists? join target-path target-file [
>  target-size: size? join target-path target-file
> ][target-size: 0]
>
> if target-size == source-size [print "Nothing to download, file already
> complete ..." halt]
> if target-size > 0 [print ["Appending at " target-size "bytes"]]
>
> start: now/time
> forever [
>
>    while [error? try [source: open/binary/direct/no-wait/skip join
> source-url source-file target-size]][
>     print "Can't open source file .... waiting 10 min"
>     wait 00:10
>    ]
>
>    while [
>      wait source
>      data: copy/part source 2048
>    ][
>      write/binary/append join target-path target-file data
>      target-size: target-size + length? data
>      print ["Source-size: " source-size tab "Downloaded: " target-size
> tab "Time: " now/time - start]
>    ]
>   if target-size >= source-size [break]
> ]
>
> close source

--
To unsubscribe from this list, please send an email to
[EMAIL PROTECTED] with "unsubscribe" in the
subject, without the quotes.

Reply via email to