W3C home > Mailing lists > Public > www-archive@w3.org > September 2002

Re: ruby put client fragment

From: Charles McCathieNevile <charles@w3.org>
Date: Wed, 25 Sep 2002 16:20:21 -0400 (EDT)
To: Dan Brickley <danbri@w3.org>
cc: <www-archive+esw@w3.org>, <libby.miller@bristol.ac.uk>
Message-ID: <Pine.LNX.4.30.0209251617500.31423-100000@tux.w3.org>

#handling redirect code

h = Net::HTTP.new(ARGV[0] || 'www.ruby-lang.org', 80)
url = ARGV[1] || '/'

begin
  resp, data = h.get(url, nil) { |a| }
rescue Net::ProtoRetriableError => detail
  head = detail.data

  if head.code == "301"
    uri = URI.create(head['location'])

    host = uri['host']
    url  = uri['path']
    port = uri['port']

    h.finish
    h = Net::HTTP.new(host,Ęport)

    retry
  end
end
Received on Wednesday, 25 September 2002 16:20:24 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Wednesday, 7 November 2012 14:17:23 GMT