lib/pwned/password_base.rb in pwned-2.2.0 vs lib/pwned/password_base.rb in pwned-2.3.0
- old
+ new
@@ -63,11 +63,11 @@
# @since 1.0.0
attr_reader :hashed_password
private
- attr_reader :request_options, :request_headers, :request_proxy
+ attr_reader :request_options, :request_headers, :request_proxy, :ignore_env_proxy
def fetch_pwned_count
for_each_response_line do |line|
next unless line.start_with?(hashed_password_suffix)
# Count starts after the suffix, followed by a colon
@@ -106,14 +106,16 @@
request = Net::HTTP::Get.new(uri)
request.initialize_http_header(request_headers)
request_options[:use_ssl] = true
+ environment_proxy = ignore_env_proxy ? nil : :ENV
+
Net::HTTP.start(
uri.host,
uri.port,
- request_proxy&.host,
+ request_proxy&.host || environment_proxy,
request_proxy&.port,
request_proxy&.user,
request_proxy&.password,
request_options
) do |http|
@@ -134,8 +136,7 @@
chunk_lines.each(&block)
end
yield last_line unless last_line.empty?
end
-
end
end