Sha256: 26d3ff7861b198db187c6f788582cd28c0de998e7ef49417fe3e672c614b6c76

Contents?: true

Size: 874 Bytes

Versions: 20

Compression:

Stored size: 874 Bytes

Contents

# frozen_string_literal: true

# Represents a site to which HTTP connections are made. It is a value
# object, and is suitable for use in a hash. If two sites are equal,
# then a persistent connection made to the first site, can be re-used
# for the second.
#
# @api private
class Puppet::HTTP::Site
  attr_reader :scheme, :host, :port

  def self.from_uri(uri)
    new(uri.scheme, uri.host, uri.port)
  end

  def initialize(scheme, host, port)
    @scheme = scheme
    @host = host
    @port = port.to_i
  end

  def addr
    "#{@scheme}://#{@host}:#{@port}"
  end
  alias to_s addr

  def ==(rhs)
    (@scheme == rhs.scheme) && (@host == rhs.host) && (@port == rhs.port)
  end

  alias eql? ==

  def hash
    [@scheme, @host, @port].hash
  end

  def use_ssl?
    @scheme == 'https'
  end

  def move_to(uri)
    self.class.new(uri.scheme, uri.host, uri.port)
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
puppet-8.10.0 lib/puppet/http/site.rb
puppet-8.10.0-x86-mingw32 lib/puppet/http/site.rb
puppet-8.10.0-x64-mingw32 lib/puppet/http/site.rb
puppet-8.10.0-universal-darwin lib/puppet/http/site.rb
puppet-8.9.0 lib/puppet/http/site.rb
puppet-8.9.0-x86-mingw32 lib/puppet/http/site.rb
puppet-8.9.0-x64-mingw32 lib/puppet/http/site.rb
puppet-8.9.0-universal-darwin lib/puppet/http/site.rb
puppet-8.8.1 lib/puppet/http/site.rb
puppet-8.8.1-x86-mingw32 lib/puppet/http/site.rb
puppet-8.8.1-x64-mingw32 lib/puppet/http/site.rb
puppet-8.8.1-universal-darwin lib/puppet/http/site.rb
puppet-8.7.0 lib/puppet/http/site.rb
puppet-8.7.0-x86-mingw32 lib/puppet/http/site.rb
puppet-8.7.0-x64-mingw32 lib/puppet/http/site.rb
puppet-8.7.0-universal-darwin lib/puppet/http/site.rb
puppet-8.6.0 lib/puppet/http/site.rb
puppet-8.6.0-x86-mingw32 lib/puppet/http/site.rb
puppet-8.6.0-x64-mingw32 lib/puppet/http/site.rb
puppet-8.6.0-universal-darwin lib/puppet/http/site.rb