2010-06-19 32 views
0

我試圖誤差試驗異步http.r在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 [] 

,我得到這個錯誤:

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

難道沒有在代碼中的錯誤?

回答

1

該錯誤消息說,你還沒有安裝異步HTTP協議(ahttp:// ahttps://)

我剛剛又試了一次,而且它適用於http://www.rebol.com

+0

哎呀對不起,我想我沒有。 – 2010-06-20 06:53:55