class HTTPClient::Connection

end
p str
while str = io.read(40)
io = connection.pop.content
connection = clnt.get_async(‘dev.ctor.org/’)
2. Read the response as an IO.
p res.status
res = connection.pop
puts ‘.’
end
sleep 1
print ‘.’
break if connection.finished?
while true
print ‘posting.’
connection = clnt.post_async(url, body)
periodically.
1. Invoke HTTP method asynchronously and check if it’s been finished
== How to use
Connection.
HTTPClient such as get_async, post_async, etc. returns an instance of
Represents a HTTP response to an asynchronous request. Async methods of

def finished?

Checks if the asynchronous invocation has been finished or not.
def finished?
  if !@async_thread
    # Not in async mode.
    true
  elsif @async_thread.alive?
    # Working...
    false
  else
    # Async thread have been finished.
    join
    true
  end
end

def initialize(header_queue = [], body_queue = []) # :nodoc:

:nodoc:
def initialize(header_queue = [], body_queue = []) # :nodoc:
  @headers = header_queue
  @body = body_queue
  @async_thread = nil
  @queue = Queue.new
end

def join

Waits the completion of the asynchronous invocation.
def join
  if @async_thread
    @async_thread.join
  end
  nil
end

def pop

method twice for now. The second invocation will be blocked.
Retrieves a HTTP::Message instance of HTTP response. Do not invoke this
def pop
  response_or_exception = @queue.pop
  if response_or_exception.is_a? Exception
    raise response_or_exception
  end
  response_or_exception
end

def push(result) # :nodoc:

:nodoc:
def push(result) # :nodoc:
  @queue.push(result)
end