Sha256: 65eec39b2ebc0bccc0a3074e08cf04f6d1bda49f68b8f61192bbda454b0d11d1

Contents?: true

Size: 587 Bytes

Versions: 1

Compression:

Stored size: 587 Bytes

Contents

require 'vacuum'
require 'em-http-request'

module Vacuum
  class Request
    # Performs an async request.
    #
    # @param err [Proc] A callback to be executed if request fails
    # @yield Passes response to given block
    def aget(err = nil, &blk)
      http = EM::HttpRequest.new(url).get
      # @todo Consider using a SAX parser that can work on the chunks as they
      # come in?
      # http.stream { |chunk| parse chunk }
      http.callback do
        yield Response.new http.response, http.response_header.status
      end
      http.errback &err if err
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
vacuum-0.1.3 lib/vacuum/em.rb