From: Ian Macdonald Date: 2003-06-06T03:05:19+09:00 Subject: Re: Ruby 1.8.0 net/http bug On Fri 06 Jun 2003 at 02:54:03 +0900, Urban Nilsson wrote: > I tried the following example code: > > require 'net/http' > h = Net::HTTP.new('www.pragmaticprogrammer.com', 80) > resp, data = h.get('/index.html', nil) > puts "Code = #{resp.code}" > puts "Message = #{resp.message}" > resp.each {|val, key| printf "%-14s = %-40.40s\n", key, val } > p data[0..55] > > > This ran as expected under ruby 1.6.7 (2002-03-01) [powerpc-darwin6.0] > but when I ran it under ruby 1.8.0 (2003-05-26) [powerpc-darwin6.6] the > data variable was nil, resulting in a "net.rb:8: undefined method `[]' > for nil (NoMethodError)". resp was the same under both versions however. > > What can I do to narrow this problem down? After: resp, data = h.get('/index.html', nil) try adding this line: data = resp.data if data.nil? That should make your code compatible with both versions of net/http. Ian -- Ian Macdonald | From the cradle to the coffin underwear System Administrator | comes first. -- Bertolt Brecht ian@caliban.org | http://www.caliban.org | |