Sha256: b1bcd380e8da89abb5df3dbd80fd8ec56643b152e29f4cf41023db0ccfb474ae
Contents?: true
Size: 1.17 KB
Versions: 19
Compression:
Stored size: 1.17 KB
Contents
require 'typhoeus' module Acfs module Adapter # Adapter for Typhoeus. # class Typhoeus < Base def initialize(**kwargs) @options = kwargs end def start hydra.run rescue @hydra = nil raise end delegate :abort, to: :hydra def run(request) convert_request(request).run end def queue(request) hydra.queue convert_request request end protected def hydra @hydra ||= ::Typhoeus::Hydra.new(**@options) end def convert_request(req) request = ::Typhoeus::Request.new req.url, method: req.method, params: req.params, headers: req.headers.merge( 'Expect' => '', 'Transfer-Encoding' => '' ), body: req.body request.on_complete do |response| req.complete! convert_response(req, response) end request end def convert_response(request, response) Acfs::Response.new request, status: response.code, headers: response.headers, body: response.body end end end end
Version data entries
19 entries across 19 versions & 1 rubygems