diff --git a/lib/webmock/util/headers.rb b/lib/webmock/util/headers.rb index 052c84a0..e858c1e4 100644 --- a/lib/webmock/util/headers.rb +++ b/lib/webmock/util/headers.rb @@ -1,7 +1,5 @@ # frozen_string_literal: true -require 'base64' - module WebMock module Util @@ -59,7 +57,8 @@ def self.decode_userinfo_from_header(header) end def self.basic_auth_header(*credentials) - "Basic #{Base64.strict_encode64(credentials.join(':')).chomp}" + strict_base64_encoded = [credentials.join(':')].pack("m0") + "Basic #{strict_base64_encoded.chomp}" end def self.normalize_name(name) diff --git a/spec/acceptance/async_http_client/async_http_client_spec_helper.rb b/spec/acceptance/async_http_client/async_http_client_spec_helper.rb index 4f6b42c5..954271c2 100644 --- a/spec/acceptance/async_http_client/async_http_client_spec_helper.rb +++ b/spec/acceptance/async_http_client/async_http_client_spec_helper.rb @@ -11,7 +11,7 @@ def http_request(method, url, options = {}, &block) end end headers.push( - ['authorization', 'Basic ' + Base64.strict_encode64(options[:basic_auth].join(':'))] + ['authorization', WebMock::Util::Headers.basic_auth_header(options[:basic_auth])] ) if options[:basic_auth] body = options[:body]