Skip to main content

  | मौसम…

411 समाचार
Public archive edition · Attributed source reporting with original dates · AI drafts are excluded

411 REFERENCE · Wikibooks

Rebol Programming/read-net

Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.

USAGE: READ-NET url /progress callback DESCRIPTION: Read a file from the net (web). Update progress bar. Allow abort. READ-NET is a function value. ARGUMENTS url -- (Type: url) REFINEMENTS /progress callback -- Call func [total bytes] during transfer. Return true. (Type: any) SOURCE CODE read-net: func [ {Read a file from the net (web). Update progress bar. Allow abort.} url [url!] /progress callback {Call func [total bytes] during transfer. Return true.} /local port buffer data size ][ vbug ['read-net url] if error? try [port: open/direct url] [return none] size: to-integer any [port/locals/headers/content-length 8000] buffer: make binary! size set-modes port/sub-port [lines: false binary: true no-wait: true] until [ if not data: wait [60 port/sub-port] [data: true break] if data: copy port/sub-port [append buffer data] all [:callback size not callback size length? buffer data: true break] not data ] close port if not data [buffer] ]