diff --git a/Gemfile b/Gemfile index 12f59ee3..5a4e34ef 100644 --- a/Gemfile +++ b/Gemfile @@ -24,8 +24,9 @@ # THE SOFTWARE. #-------------------------------------------------------------------------- source "https://rubygems.org" do - gem "faraday", "~> 1.0", :require => false - gem "faraday_middleware", "~> 1.0.0.rc1", :require => false + gem "faraday", "~> 2.0", :require => false + gem "faraday-follow_redirects", "~> 0.3.0", :require => false + gem "faraday-net_http_persistent", "~> 2.0", :require => false gem "net-http-persistent", "~> 4.0", :require => false gem "nokogiri", "~> 1", ">= 1.10.8", :require => false gem "adal", "~> 1.0", :require => false diff --git a/common/azure-storage-common.gemspec b/common/azure-storage-common.gemspec index 2a614e58..e48e232f 100644 --- a/common/azure-storage-common.gemspec +++ b/common/azure-storage-common.gemspec @@ -41,8 +41,9 @@ Gem::Specification.new do |s| s.required_ruby_version = ">= 2.3.0" - s.add_runtime_dependency('faraday', '~> 1.0') - s.add_runtime_dependency('faraday_middleware', "~> 1.0", ">= 1.0.0.rc1") + s.add_runtime_dependency('faraday', '~> 2.0') + s.add_runtime_dependency('faraday-follow_redirects','~> 0.3.0') + s.add_runtime_dependency('faraday-net_http_persistent', '~> 2.0') s.add_runtime_dependency("net-http-persistent", '~> 4.0') s.add_runtime_dependency("nokogiri", "~> 1", ">= 1.10.8") s.add_development_dependency("dotenv", "~> 2.0") diff --git a/common/lib/azure/core.rb b/common/lib/azure/core.rb index 4bdf2866..21fdd327 100644 --- a/common/lib/azure/core.rb +++ b/common/lib/azure/core.rb @@ -16,7 +16,8 @@ require 'rubygems' require 'nokogiri' require 'faraday' -require 'faraday_middleware' +require 'faraday/follow_redirects' +require 'faraday/net_http_persistent' module Azure module Core diff --git a/common/lib/azure/storage/common/autoload.rb b/common/lib/azure/storage/common/autoload.rb index 57b1db17..5fef99ee 100644 --- a/common/lib/azure/storage/common/autoload.rb +++ b/common/lib/azure/storage/common/autoload.rb @@ -30,7 +30,7 @@ require "openssl" require "uri" require "faraday" -require "faraday_middleware" +require 'faraday/follow_redirects' require "azure/storage/common/core/autoload" require "azure/storage/common/default" diff --git a/common/lib/azure/storage/common/client_options.rb b/common/lib/azure/storage/common/client_options.rb index cb768300..056088a3 100644 --- a/common/lib/azure/storage/common/client_options.rb +++ b/common/lib/azure/storage/common/client_options.rb @@ -283,7 +283,7 @@ def is_base64_encoded def is_url Proc.new do |i| i = "http://" + i unless i =~ /\Ahttps?:\/\// - i =~ URI.regexp(["http", "https"]) + i =~ URI::DEFAULT_PARSER.make_regexp(["http", "https"]) end end diff --git a/common/lib/azure/storage/common/core/http_client.rb b/common/lib/azure/storage/common/core/http_client.rb index 4fdc06f4..d05abd20 100644 --- a/common/lib/azure/storage/common/core/http_client.rb +++ b/common/lib/azure/storage/common/core/http_client.rb @@ -71,7 +71,7 @@ def build_http(uri) URI::parse(ENV["HTTPS_PROXY"]) end || nil Faraday.new(uri, ssl: ssl_options, proxy: proxy_options) do |conn| - conn.use FaradayMiddleware::FollowRedirects + conn.response :follow_redirects #use Faraday::FollowRedirects::Middleware conn.adapter :net_http_persistent, pool_size: 5 do |http| # yields Net::HTTP::Persistent http.idle_timeout = 100 diff --git a/common/lib/azure/storage/common/service/storage_service.rb b/common/lib/azure/storage/common/service/storage_service.rb index e223009c..b606cdd6 100644 --- a/common/lib/azure/storage/common/service/storage_service.rb +++ b/common/lib/azure/storage/common/service/storage_service.rb @@ -239,8 +239,8 @@ class << self # Registers the callback when sending the request # The headers in the request can be viewed or changed in the code block - def register_request_callback - @request_callback = Proc.new + def register_request_callback(&block) + @request_callback = block end # Get the request location. diff --git a/table/lib/azure/storage/table/table_service.rb b/table/lib/azure/storage/table/table_service.rb index 6357b645..d560c479 100644 --- a/table/lib/azure/storage/table/table_service.rb +++ b/table/lib/azure/storage/table/table_service.rb @@ -746,7 +746,7 @@ def encodeODataUriValue(value) value = value.gsub("'", "''") # Encode the special URL characters - value = URI.escape(value) + value = URI.encode_www_form_component(value) value end