From: Sam Gentle Date: 2006-07-27T12:06:12+09:00 Subject: Re: how to get an IO object for the response from an HTTP get? On 7/27/06, Tim Olsen wrote: > Hi, > > I'd like to get an IO object instead of a string for the response of > an HTTP get. I am using the Net/HTTP library but it seems to only > want to give me a string. I have a situation where the response can > be quite large and do not want the whole response to have to be in > memory. > > Is it possible to get an IO object for the response without putting > the whole response in memory? It's possible to pass a block to HTTPResponse#get, which will yield a chunk of data each time. That said, you're probably better served by using open-uri, which lets you do this: require 'open-uri' open('http://www.google.com') do |f| #f is an IO object, yay! end Sam