Sha256: 634663b4d65af9396be2f7950c98756d805f19d90e0cf0e6825255d9e86c44af
Contents?: true
Size: 1.35 KB
Versions: 17
Compression:
Stored size: 1.35 KB
Contents
# -*- coding: utf-8 -*- module Handsoap module Http module Drivers class EventMachineDriver < AbstractDriver def self.load! require 'eventmachine' require 'em-http' end def send_http_request_async(request) emr = EventMachine::HttpRequest.new(request.url) if request.username && request.password # TODO: Verify that this is actually supported? request.headers['authorization'] = [request.username, request.password] end case request.http_method when :get emdef = emr.get(:head => request.headers) when :post emdef = emr.post(:head => request.headers, :body => request.body) when :put emdef = emr.put(:head => request.headers, :body => request.body) when :delete emdef = emr.delete else raise "Unsupported request method #{request.http_method}" end deferred = Handsoap::Deferred.new emdef.callback do http_response = parse_http_part(emdef.response_header, emdef.response, emdef.response_header.status) deferred.trigger_callback http_response end emdef.errback do deferred.trigger_errback emdef end deferred end end end end end
Version data entries
17 entries across 17 versions & 3 rubygems