mirror of
https://github.com/HoneyryderChuck/httpx.git
synced 2025-10-04 00:00:37 -04:00
prepare for base64 being removed from default gems
This commit is contained in:
parent
e4869e1a4b
commit
c7ccc9eaf6
@ -6,4 +6,5 @@ SimpleCov.start do
|
||||
add_filter "/integration_tests/"
|
||||
add_filter "/regression_tests/"
|
||||
add_filter "/lib/httpx/plugins/internal_telemetry.rb"
|
||||
add_filter "/lib/httpx/base64.rb"
|
||||
end
|
||||
|
27
lib/httpx/base64.rb
Normal file
27
lib/httpx/base64.rb
Normal file
@ -0,0 +1,27 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
if RUBY_VERSION < "3.3.0"
|
||||
require "base64"
|
||||
elsif !defined?(Base64)
|
||||
module HTTPX
|
||||
# require "base64" will not be a default gem after ruby 3.4.0
|
||||
module Base64
|
||||
module_function
|
||||
|
||||
def decode64(str)
|
||||
str.unpack1("m")
|
||||
end
|
||||
|
||||
def strict_encode64(bin)
|
||||
[bin].pack("m0")
|
||||
end
|
||||
|
||||
def urlsafe_encode64(bin, padding: true)
|
||||
str = strict_encode64(bin)
|
||||
str.chomp!("==") or str.chomp!("=") unless padding
|
||||
str.tr!("+/", "-_")
|
||||
str
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -1,6 +1,6 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require "base64"
|
||||
require "httpx/base64"
|
||||
|
||||
module HTTPX
|
||||
module Plugins
|
||||
|
@ -1,6 +1,6 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require "base64"
|
||||
require "httpx/base64"
|
||||
require "ntlm"
|
||||
|
||||
module HTTPX
|
||||
|
@ -1,7 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require "base64"
|
||||
|
||||
module HTTPX
|
||||
module Plugins
|
||||
module Authentication
|
||||
|
@ -13,7 +13,6 @@ module HTTPX
|
||||
|
||||
class << self
|
||||
def load_dependencies(klass)
|
||||
require "base64"
|
||||
klass.plugin(:upgrade)
|
||||
end
|
||||
|
||||
|
@ -1,7 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require "base64"
|
||||
|
||||
module HTTPX
|
||||
module Plugins
|
||||
module Proxy
|
||||
|
@ -4,6 +4,7 @@ require "resolv"
|
||||
require "uri"
|
||||
require "cgi"
|
||||
require "forwardable"
|
||||
require "httpx/base64"
|
||||
|
||||
module HTTPX
|
||||
class Resolver::HTTPS < Resolver::Resolver
|
||||
|
Loading…
x
Reference in New Issue
Block a user