Sha256: f4d2e02258fb076b1ef7277c9b4ba457b19dfc661b78916be28e3dc721546a88

Contents?: true

Size: 467 Bytes

Versions: 1

Compression:

Stored size: 467 Bytes

Contents

require 'swirl/ec2'
require 'em-http'

module Swirl
  class EC2
    def post(body, &blk)
      headers = { "Content-Type" => "application/x-www-form-urlencoded" }

      http = EM::HttpRequest.new(@url.to_s)
      req  = http.post(:head => headers, :body => body)

      req.callback do
        blk.call(req.response_header.status, req.response)
      end

      req.errback do
        raise "Invalid HTTP Request: #{@url}\n"+req.response
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
swirl-1.6.0 lib/swirl/ec2/em.rb