# File rice/url.rb, line 81 def fetchHTTP http = Net::HTTP.new(@host, @port) # If authentication is required, prepare the proper HTTP header. auth = nil if @username auth = { 'authorization' => 'Basic ' + ["#{@username}:#{@password}"].pack('m').gsub(/\+/, '') } end # Read headers (ignored) and document body body = nil path = @path begin response, body = http.get(@path, auth) rescue Net::ProtoRetriableError => e head = e.data if head.code == '301' # Moved permanently url = URL.parse(head['location']) http.finish() http = Net::HTTP.new(url.host, url.port) path = url.path retry end end return body end