lib/ezid/client.rb in ezid-client-1.7.1 vs lib/ezid/client.rb in ezid-client-1.8.0
- old
+ new
@@ -42,26 +42,31 @@
def version
"ezid-client #{VERSION} (EZID API Version #{API_VERSION})"
end
end
- attr_reader :user, :password, :host, :port, :use_ssl, :timeout
+ attr_reader :user, :password, :host, :port, :timeout
def initialize(opts = {})
@host = opts[:host] || config.host
@port = (opts[:port] || config.port).to_i
- @use_ssl = opts[:use_ssl] || config.use_ssl
@timeout = (opts[:timeout] || config.timeout).to_i
@user = opts[:user] || config.user
@password = opts[:password] || config.password
if block_given?
login
yield self
logout
end
end
+ def use_ssl
+ warn "[DEPRECATION] `use_ssl` is deprecated and will be removed in ezid-client v2.0." \
+ " EZID requires SSL as of April 30, 2017."
+ true
+ end
+
def inspect
"#<#{self.class.name} connection=#{connection.inspect}, " \
"user=#{user.inspect}, session=#{logged_in? ? 'OPEN' : 'CLOSED'}>"
end
@@ -186,18 +191,14 @@
@connection ||= build_connection
end
private
- def use_ssl?
- use_ssl || port == 443
- end
-
def build_connection
- conn = Net::HTTP.new(host, port)
- conn.use_ssl = use_ssl?
- conn.read_timeout = timeout
- conn
+ Net::HTTP.new(host, port).tap do |conn|
+ conn.use_ssl = true
+ conn.read_timeout = timeout
+ end
end
def handle_response(response, request_name)
log_level = response.error? ? Logger::ERROR : Logger::INFO
message = "EZID #{request_name} -- #{response.status_line}"