Sha256: 356a8b2286ceca3a36b8eade5b384a359ab84c32ac184e3bc5c1d77b658508f4

Contents?: true

Size: 802 Bytes

Versions: 5

Compression:

Stored size: 802 Bytes

Contents

module PostageApp::HTTP
  # == Moduule Methods ======================================================

  def self.connect(config)
    connector =
      if (config.proxy?)
        Net::HTTP::Proxy(
          config.proxy_host,
          config.proxy_port || SOCKS5_PORT_DEFAULT,
          config.proxy_user,
          config.proxy_pass
        )
      else
        Net::HTTP
      end

    http = connector.new(config.host, config.port)

    unless (config.verify_certificate?)
      context = OpenSSL::SSL::SSLContext.new
      context.verify_mode = OpenSSL::SSL::VERIFY_NONE

      http.send(:instance_variable_set, :@ssl_context, context)
    end

    http.read_timeout = config.http_read_timeout
    http.open_timeout = config.http_open_timeout
    http.use_ssl = config.secure?

    http
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
postageapp-1.4.2 lib/postageapp/http.rb
postageapp-1.4.1 lib/postageapp/http.rb
postageapp-1.4.0 lib/postageapp/http.rb
postageapp-1.3.1 lib/postageapp/http.rb
postageapp-1.3.0 lib/postageapp/http.rb