Sha256: a0a3d9c315fcddd17b2fcc71ad23839b692bb0db044391b0db73e081f40884a0
Contents?: true
Size: 962 Bytes
Versions: 6
Compression:
Stored size: 962 Bytes
Contents
require 'curl' module Animoto class HTTPEngine class CurlAdapter < Animoto::HTTPEngine def request method, url, body = nil, headers = {}, options = {} curl = build_curl method, url, body, headers, options perform curl, method check_response curl.response_code, curl.body_str curl.body_str end private def build_curl method, url, body, headers, options ::Curl::Easy.new(url) do |c| c.username = options[:username] c.password = options[:password] c.timeout = options[:timeout] c.post_body = body headers.each { |header, value| c.headers[header] = value } end end def perform curl, method case method when :get curl.http_get when :post curl.http_post(body) end end end adapter_map.merge! :curl => CurlAdapter end end
Version data entries
6 entries across 6 versions & 1 rubygems