Object
Represents a HTTP response to an asynchronous request. Async methods of HTTPClient such as get_async, post_async, etc. returns an instance of Connection.
Invoke HTTP method asynchronously and check if it’s been finished periodically.
connection = clnt.post_async(url, body) print 'posting.' while true break if connection.finished? print '.' sleep 1 end puts '.' res = connection.pop p res.status
Read the response as an IO.
connection = clnt.get_async('http://dev.ctor.org/') io = connection.pop.content while str = io.read(40) p str end
Checks if the asynchronous invocation has been finished or not.
# File lib/httpclient/connection.rb, line 50 50: def finished? 51: if !@async_thread 52: # Not in async mode. 53: true 54: elsif @async_thread.alive? 55: # Working... 56: false 57: else 58: # Async thread have been finished. 59: join 60: true 61: end 62: end
Waits the completion of the asynchronous invocation.
# File lib/httpclient/connection.rb, line 75 75: def join 76: if @async_thread 77: @async_thread.join 78: end 79: nil 80: end
Retrieves a HTTP::Message instance of HTTP response. Do not invoke this method twice for now. The second invocation will be blocked.
# File lib/httpclient/connection.rb, line 66 66: def pop 67: @queue.pop 68: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.