def http_request
      if http_proxy
        http_request = http_proxy.new(url.host, url.port)
      else
        http_request = Net::HTTP.new(url.host, url.port)
      end
      
      # enable SSL/TLS
      if url.scheme == 'https'
        require 'net/https'
        require 'openssl'
        Error::Connection.extend_classes!
        
        http_request.use_ssl = true
        
        if options[:tls_verify] or options[:verify_ssl]
          if http_request.respond_to?(:enable_post_connection_check=)
            http_request.enable_post_connection_check = true
          end
          # from http://curl.haxx.se/ca/cacert.pem
          http_request.ca_file = options[:tls_ca_file] || File.expand_path('../../../support/cacert.pem', __FILE__)
          http_request.verify_mode = OpenSSL::SSL::VERIFY_PEER
        else
          http_request.verify_mode = OpenSSL::SSL::VERIFY_NONE
        end
        
        if options[:tls_key_and_certificate_file]
          key_and_certificate       = File.read(options[:tls_key_and_certificate_file])
          options[:tls_key]         = OpenSSL::PKey::RSA.new(key_and_certificate)
          options[:tls_certificate] = OpenSSL::X509::Certificate.new(key_and_certificate)
        end
        
        if options[:tls_key] and options[:tls_certificate]
          http_request.key  = options[:tls_key]
          http_request.cert = options[:tls_certificate]
        elsif options[:tls_key] || options[:tls_certificate]
          raise ArgumentError, "Please specify both the certificate and private key (:tls_key and :tls_certificate)"
        end
      end
      
      if @configure_block
        @configure_block.call(http_request)
      end
      
      http_request
    end
def http_request
      if http_proxy
        http_request = http_proxy.new(url.host, url.port)
      else
        http_request = Net::HTTP.new(url.host, url.port)
      end
      
      # enable SSL/TLS
      if url.scheme == 'https'
        require 'net/https'
        require 'openssl'
        Error::Connection.extend_classes!
        
        http_request.use_ssl = true
        
        if options[:tls_verify] or options[:verify_ssl]
          if http_request.respond_to?(:enable_post_connection_check=)
            http_request.enable_post_connection_check = true
          end
          # from http://curl.haxx.se/ca/cacert.pem
          http_request.ca_file = options[:tls_ca_file] || File.expand_path('../../../support/cacert.pem', __FILE__)
          http_request.verify_mode = OpenSSL::SSL::VERIFY_PEER
        else
          http_request.verify_mode = OpenSSL::SSL::VERIFY_NONE
        end
        
        if options[:tls_key_and_certificate_file]
          key_and_certificate       = File.read(options[:tls_key_and_certificate_file])
          options[:tls_key]         = OpenSSL::PKey::RSA.new(key_and_certificate)
          options[:tls_certificate] = OpenSSL::X509::Certificate.new(key_and_certificate)
        end
        
        if options[:tls_key] and options[:tls_certificate]
          http_request.key  = options[:tls_key]
          http_request.cert = options[:tls_certificate]
        elsif options[:tls_key] || options[:tls_certificate]
          raise ArgumentError, "Please specify both the certificate and private key (:tls_key and :tls_certificate)"
        end
      end
      
      if @configure_block
        @configure_block.call(http_request)
      end
      
      http_request
    end
Configures and returns a new <tt>Net::HTTP</tt> request object