From: Aaron Malone Date: 2001-09-25T08:13:07+09:00 Subject: [ruby-talk:21651] Re: Newbie: Help with Ruby web programming On Tue, Sep 25, 2001 at 07:51:22AM +0900, vart@mailandnews.com wrote: > I'm using eRuby, but am having a tough time trying to do the following: Suppose > I have an URL > http://www.somehere.com/some/goodthing?with=params&rest=stuff > I would like to: > 1) Check to see if the URL is valid (ie: actually points to something) and dete > rmine if I get a 404 (file not found) or some other error. Have you looked into the Net::HTTP class? Some simple code to see if something exists or not could run something like: require 'net/http' h = Net::HTTP.new('munge.net') begin resp, data = h.get('/doesntexist?foo=bar') rescue Net::ProtoFatalError => splat print "Are you sure about that? -- " + splat end -- Aaron Malone (aaron@semo.net) "Clothes make the man. System Administrator Naked people have little or Poplar Bluff Internet, Inc. no influence on society." http://www.semo.net -- Mark Twain