From 06b7fa2d12706072db85a8deb3479936bde8f622 Mon Sep 17 00:00:00 2001 From: Ankit Honey Date: Wed, 19 Apr 2023 18:34:36 -0700 Subject: [PATCH 1/6] Updating faraday to version 2.0 Updating faraday to version 2.0 --- common/azure-storage-common.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/azure-storage-common.gemspec b/common/azure-storage-common.gemspec index 2a614e58..540b3c3a 100644 --- a/common/azure-storage-common.gemspec +++ b/common/azure-storage-common.gemspec @@ -41,7 +41,7 @@ Gem::Specification.new do |s| s.required_ruby_version = ">= 2.3.0" - s.add_runtime_dependency('faraday', '~> 1.0') + s.add_runtime_dependency('faraday', '~> 2.0') s.add_runtime_dependency('faraday_middleware', "~> 1.0", ">= 1.0.0.rc1") s.add_runtime_dependency("net-http-persistent", '~> 4.0') s.add_runtime_dependency("nokogiri", "~> 1", ">= 1.10.8") From ddd625ee3e4757f79decbb9a8ce6f341a1e992ed Mon Sep 17 00:00:00 2001 From: Ankit Honey Date: Wed, 19 Apr 2023 18:51:07 -0700 Subject: [PATCH 2/6] Update faraday to version 1.0 in Gemfile --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 12f59ee3..4e8ce3c0 100644 --- a/Gemfile +++ b/Gemfile @@ -24,7 +24,7 @@ # THE SOFTWARE. #-------------------------------------------------------------------------- source "https://rubygems.org" do - gem "faraday", "~> 1.0", :require => false + gem "faraday", "~> 2.0", :require => false gem "faraday_middleware", "~> 1.0.0.rc1", :require => false gem "net-http-persistent", "~> 4.0", :require => false gem "nokogiri", "~> 1", ">= 1.10.8", :require => false From f7b2c9de011bbea2824b8fbe008077762c780fc7 Mon Sep 17 00:00:00 2001 From: Ankit Kumar Honey Date: Thu, 20 Apr 2023 15:57:20 -0700 Subject: [PATCH 3/6] Upgrading faraday from version 1.0.0 to 2.0.0 --- Gemfile | 3 ++- common/azure-storage-common.gemspec | 3 ++- common/lib/azure/core.rb | 3 ++- common/lib/azure/storage/common/autoload.rb | 2 +- common/lib/azure/storage/common/core/http_client.rb | 2 +- 5 files changed, 8 insertions(+), 5 deletions(-) diff --git a/Gemfile b/Gemfile index 4e8ce3c0..5a4e34ef 100644 --- a/Gemfile +++ b/Gemfile @@ -25,7 +25,8 @@ #-------------------------------------------------------------------------- source "https://rubygems.org" do gem "faraday", "~> 2.0", :require => false - gem "faraday_middleware", "~> 1.0.0.rc1", :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 540b3c3a..e48e232f 100644 --- a/common/azure-storage-common.gemspec +++ b/common/azure-storage-common.gemspec @@ -42,7 +42,8 @@ Gem::Specification.new do |s| s.required_ruby_version = ">= 2.3.0" s.add_runtime_dependency('faraday', '~> 2.0') - s.add_runtime_dependency('faraday_middleware', "~> 1.0", ">= 1.0.0.rc1") + 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/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 From c959872372b3982850d1ec77354de3ed7b9f6a96 Mon Sep 17 00:00:00 2001 From: Ankit Honey Date: Wed, 26 Apr 2023 11:16:54 -0700 Subject: [PATCH 4/6] replaced the obsolete URI.escape method with URI.encode_www_form_component Replaced the URI.escape method with URI.encode_www_form_component as URI.escape method is obsolete. --- table/lib/azure/storage/table/table_service.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From a67ad610fbefa891ae5af9686b2171200bb4c70b Mon Sep 17 00:00:00 2001 From: Ankit Honey Date: Wed, 26 Apr 2023 11:31:29 -0700 Subject: [PATCH 5/6] Replaced obsolete URI.regexp method with URI::DEFAULT_PARSER.make_regexp --- common/lib/azure/storage/common/client_options.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From abae3ba18d5ba169bf83685d372e1be56748d6b4 Mon Sep 17 00:00:00 2001 From: Ankit Kumar Honey Date: Wed, 26 Apr 2023 17:24:00 -0700 Subject: [PATCH 6/6] fixed the unit test case with ArgumentError: tried to create Proc object without a block --- common/lib/azure/storage/common/service/storage_service.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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.