Sha256: e312f208e8018c0214d37153b761dd8ae031d1caa039553fb0c0b636f9d029fa
Contents?: true
Size: 1.07 KB
Versions: 5
Compression:
Stored size: 1.07 KB
Contents
module Keen module HTTP class Sync def initialize(host, port, options={}) require 'net/https' @http = Net::HTTP.new(host, port) options.each_pair { |key, value| @http.send "#{key}=", value } end def post(options) path, headers, body = options.values_at( :path, :headers, :body) @http.post(path, body, headers) end end class Async def initialize(host, port, options={}) if defined?(EventMachine) && EventMachine.reactor_running? require 'em-http-request' else raise Error, "An EventMachine loop must be running to use publish_async calls" end @host, @port, @http_options = host, port, options end def post(options) path, headers, body = options.values_at( :path, :headers, :body) uri = "https://#{@host}:#{@port}#{path}" http_client = EventMachine::HttpRequest.new(uri, @http_options) http_client.post( :body => body, :head => headers ) end end end end
Version data entries
5 entries across 5 versions & 1 rubygems
Version | Path |
---|---|
keen-0.5.0 | lib/keen/http.rb |
keen-0.4.4 | lib/keen/http.rb |
keen-0.4.3 | lib/keen/http.rb |
keen-0.4.2 | lib/keen/http.rb |
keen-0.4.1 | lib/keen/http.rb |