Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] Re: R: Re: redirecting from http to ftp

From: ryan:christiansen:intellisol at: 29-Jun-2001 11:04

Hmm... I tried this function, but it doesn't seem to behave any differently than using 'open. -Ryan
> OK. So how can I fix it? I want the script to at least error out instead
of
> keep trying over and over again. Using an if error? try statement doesn't > help.
I'm new with rebol, but to learn i have written this script. ------------------------------------------------------------------------------ REBOL[ Title: "Redirecting HTTP to FTP" Author: "Romano Paolo Tenca" Version: 1.0.0 Date: 29/06/01 Purpose: { Try a http url if fail for error 800 (redirect to a ftp site) return a custom object (redir) with info for the ftp Perhaps worked better if it was an object with a public routine embedded but it is my first Rebol routine } History: [ "It doesn't check ftp error" 29/06/01 ] ] HttpRedir?: function [url [url!]] [rule err porterr redir-str] [ rule:[to "http://" to "ftp://" copy redir-str to " could" "could" "not" be retrieved. "Circular" "forwarding" "detected" to end] redir: make object! [ net: "http" ;type of connection success: true ;false for failure urlpath: url ;url (http or ftp) urlob: decode-url url ;standard object! purl err: ;standard object! error type: none ;type of fftp url ("file" | "dir") ] if error? porterr: try [info? url][ err: disarm porterr redir/success: false redir/err: err if err/code = 800 [ redir-str: copy "" parse err/arg1 rule if redir-str <> "" [ redir/success: true redir/net: "ftp" redir/urlpath: to-url redir-str redir/urlob: decode-url redir-str either dir? redir/urlpath [ ;is a dir redir/type: "dir" ][ ;is a file redir/type: "file" ] ] ] ] return redir ] r: HttpRedir? http://www.bebits.com/bob/232/MailToI.zip either r/success = true [ print ["You can open" r/net r/urlpath "(ftp type" r/type ")"] ][ print ["Error on open http" r/err/code ] ]