2010-06-19 6 views
0

j'ai essayéavec Test-async-http.r dans rebol

http://rebol.wik.is/Protocols/Test-async-http.r

do %async-protocol.r 
do %async-http.r 

buffer: copy "" 
content-length: 0 

handler: func [port [port!] event [error! word!] 
] [ 
    switch event [ 
     connect [print "Connected." false] 
     read [ 
      if port/sub-port/state/inbuffer [ 
       statustxt/text: form length? port/sub-port/state/inbuffer 
       show statustxt 
       if zero? content-length [ 
        either parse/all port/sub-port/state/inbuffer [ thru "content-length: " copy content-length to newline to end ][ 
         if content-length [ 
          content-length: to-integer trim/all content-length 
         ] 
        ][ content-length: none ] 
       ] 
       if all [ content-length content-length > 0 ][ 
        prog/data: (to-integer statustxt/text)/content-length  
        show prog   
       ]  
      ] 
      false 
     ] 
     write [false] 
     close [print "Peer closed connection." append buffer copy port 
      close port 
      write/binary last split-path to-url urlfld/text buffer 
      false ; if you use true here, you'll exit the View event handler as well 
     ] 
    ] 
] 

do-download: has [url link ][ 
    if not empty? url: urlfld/text [ 
     if parse/all url [ "http" opt "s" "://" to end][ 
      insert head url 'a 
      link: open to-url url 
      link/awake: :handler   
     ] 
    ] 
] 


view/new center-face layout [ 
    across 
    label "URL: " gold urlfld: field 300 return 
    prog: progress 340x15 return 
    btn "Download" [ do-download ] return 
    label "You can type while downloading" black return 
    area 340x200 wrap 
    at 160x50 statustxt: text "bytes" 100 white 
] 

wait [] 

et j'eu cette erreur:

** Access Error: Invalid port spec: ahttp://reboltutorial.com 
** Where: do-download 
** Near: link: open to-url url 
link/awake: 
>> 

est-il pas un bug dans le code ?

Répondre

1

Ce message d'erreur vous dit n'avez pas installé le protocole async-http (ahttp: // ahttps: //)

Je viens d'essayer à nouveau, et il fonctionne sur http://www.rebol.com

+0

Oops désolé, je pensais que je fait. –