From: Brian Candler Date: 2010-05-13T23:07:26+09:00 Subject: Re: Asynchronous HTTP request Daniel DeLorme wrote: > I just want to issue the http request, do other stuff while the request > goes on its merry way, let the response accumulate at the socket, and > read the data when I'm ready to. Hmm. Well you can delay reading the body like this: http = Net::HTTP.start(...) res = http.get(...) ... do some stuff answer = res.read_body but it'll wait for the response headers before get() returns. So, you should just pick the bits you need out of /usr/lib/ruby/1.8/net/http.rb directly. Note that get() just calls request(Get.new(...)), which takes you here: def request(req, body = nil, &block) # :yield: +response+ unless started? start { req['connection'] ||= 'close' return request(req, body, &block) } end if proxy_user() unless use_ssl? req.proxy_basic_auth proxy_user(), proxy_pass() end end req.set_body_internal body begin_transport req req.exec @socket, @curr_http_version, edit_path(req.path) begin res = HTTPResponse.read_new(@socket) end while res.kind_of?(HTTPContinue) res.reading_body(@socket, req.response_body_permitted?) { yield res if block_given? } end_transport req, res res end You can see there how to send the request (req.exec), and subsequently how to read the response from the socket. -- Posted via http://www.ruby-forum.com/.