Sha256: 4f87f5d51bea7c14e1f5cbd5b66e29a0e158fbbe93981976de8def94efc10d80
Contents?: true
Size: 1.2 KB
Versions: 3
Compression:
Stored size: 1.2 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 def get(options) path, headers = options.values_at( :path, :headers) @http.get(path, 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
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
keen-0.7.0 | lib/keen/http.rb |
keen-0.6.1 | lib/keen/http.rb |
keen-0.6.0 | lib/keen/http.rb |