Skip to content

Commit

Permalink
Drop depenency on base64
Browse files Browse the repository at this point in the history
  • Loading branch information
Earlopain committed Feb 8, 2024
1 parent 017f8a6 commit 1bbb496
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 8 deletions.
1 change: 0 additions & 1 deletion http.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ Gem::Specification.new do |gem|
gem.required_ruby_version = ">= 3.0"

gem.add_runtime_dependency "addressable", "~> 2.8"
gem.add_runtime_dependency "base64", "~> 0.1"
gem.add_runtime_dependency "http-cookie", "~> 1.0"
gem.add_runtime_dependency "http-form_data", "~> 2.2"
gem.add_runtime_dependency "llhttp-ffi", "~> 0.5.0"
Expand Down
6 changes: 2 additions & 4 deletions lib/http/chainable.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# frozen_string_literal: true

require "base64"

require "http/headers"

module HTTP
Expand Down Expand Up @@ -213,9 +211,9 @@ def auth(value)
def basic_auth(opts)
user = opts.fetch(:user)
pass = opts.fetch(:pass)
creds = "#{user}:#{pass}"
strict_base64_encoded_creds = ["#{user}:#{pass}"].pack("m0")

auth("Basic #{Base64.strict_encode64(creds)}")
auth("Basic #{strict_base64_encoded_creds}")
end

# Get options for HTTP
Expand Down
5 changes: 2 additions & 3 deletions lib/http/request.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# frozen_string_literal: true

require "forwardable"
require "base64"
require "time"

require "http/errors"
Expand Down Expand Up @@ -159,8 +158,8 @@ def include_proxy_authorization_header
end

def proxy_authorization_header
digest = Base64.strict_encode64("#{proxy[:proxy_username]}:#{proxy[:proxy_password]}")
"Basic #{digest}"
strict_base64_encoded_digest = ["#{proxy[:proxy_username]}:#{proxy[:proxy_password]}"].pack("m0")
"Basic #{strict_base64_encoded_digest}"
end

# Setup tunnel through proxy for SSL request
Expand Down

0 comments on commit 1bbb496

Please sign in to comment.