From: Eric Hodel Date: 2002-12-10T05:36:52+09:00 Subject: Re: 302 --kA1LkgxZ0NN7Mz3A Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Basti S (basti.steiner@gmx.de) wrote: > Hi, > i'm usin ver 1.6.7 of ruby . Everytime I try to access a site via Net::HT= TP > and this site has a 302 response code it says >=20 > /net/http.rb:1432: in error! : 302 "Found" (Net::ProtoRetriableError) >=20 > Ruby terminates the script with this errormessage. But I want to read out > the new location of the url. Does anybody know how to get this url or if > there is any possibility to solve this problem? Line 71 of /usr/local/lib/ruby/1.6/net/http.rb is your friend! =3D=3D=3D Redirect require 'net/http' Net::HTTP.version_1_1 # declear to use 1.1 features. host =3D 'www.ruby-lang.org' path =3D '/' begin Net::HTTP.start( host, 80 ) {|http| response , =3D http.get(path) print response.body } rescue Net::ProtoRetriableError =3D> err if m =3D %r.match( err.response['location'] ) then host =3D m[1].strip path =3D m.post_match retry end end --=20 Eric Hodel - drbrain@segment7.net - http://segment7.net All messages signed with fingerprint: FEC2 57F1 D465 EB15 5D6E 7C11 332A 551C 796C 9F04 --kA1LkgxZ0NN7Mz3A Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.0 (FreeBSD) iD8DBQE99P7iMypVHHlsnwQRAqNzAKCdcALP9yC3yQNNLppkNEc3qnoS8QCgp1rM uv2d9fERBZt9MQEdI0z3ZiQ= =YtOe -----END PGP SIGNATURE----- --kA1LkgxZ0NN7Mz3A--