Sha256: 0d78c736d191a31f1524aef676e35d28807d12c1a548cc8b7262c51a36b49a94

Contents?: true

Size: 596 Bytes

Versions: 11

Compression:

Stored size: 596 Bytes

Contents

require 'net/http'

module RequestWithSocketCheck
  def self.included(base)
    base.instance_eval do
      alias_method :request_without_socket_check, :request
      alias_method :request, :request_with_socket_check
    end
  end
  
  def request_with_socket_check(*args)
    begin
      request_without_socket_check(*args)
    rescue NoMethodError => e
      if e.message =~ /undefined method `closed\?' for nil/
        raise Errno::ECONNREFUSED
      else
        raise e
      end
    end
  end
end

if Net::HTTP::Revision.to_i == 25851
  Net::HTTP.send :include, RequestWithSocketCheck
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
iCuke-0.6.3 lib/icuke/core_ext.rb
iCuke-0.6.2 lib/icuke/core_ext.rb
iCuke-0.6.1 lib/icuke/core_ext.rb
iCuke-0.6.0 lib/icuke/core_ext.rb
iCuke-0.5.5 lib/icuke/core_ext.rb
iCuke-0.5.4 lib/icuke/core_ext.rb
iCuke-0.5.3 lib/icuke/core_ext.rb
iCuke-0.5.2 lib/icuke/core_ext.rb
iCuke-0.5.1 lib/icuke/core_ext.rb
iCuke-0.4.8 lib/icuke/core_ext.rb
iCuke-0.4.7 lib/icuke/core_ext.rb