From 0aa5a4962daaa198f944229ea554a182314060d6 Mon Sep 17 00:00:00 2001 From: AbeCole Date: Thu, 25 May 2023 20:44:53 +0100 Subject: [PATCH 1/3] Proxy config options added --- lib/docraptor/api_client.rb | 2 ++ lib/docraptor/configuration.rb | 12 ++++++++++++ 2 files changed, 14 insertions(+) diff --git a/lib/docraptor/api_client.rb b/lib/docraptor/api_client.rb index 0274b07..89c4626 100644 --- a/lib/docraptor/api_client.rb +++ b/lib/docraptor/api_client.rb @@ -111,6 +111,8 @@ def build_request(http_method, path, opts = {}) :sslcert => @config.cert_file, :sslkey => @config.key_file, :verbose => @config.debugging, + :proxy => @config.proxy, + :proxyuserpwd => @config.proxyuserpwd, :followlocation => follow_location } diff --git a/lib/docraptor/configuration.rb b/lib/docraptor/configuration.rb index 00148d3..de7629d 100644 --- a/lib/docraptor/configuration.rb +++ b/lib/docraptor/configuration.rb @@ -133,6 +133,16 @@ class Configuration # https://github.com/typhoeus/ethon/blob/master/lib/ethon/easy/queryable.rb#L96 attr_accessor :params_encoding + # Proxy URL to pass to Typhoeus. + # Default to nil. + attr_accessor :proxy + + # Proxy username & password to pass to Typhoeus. + # Format as `username:password`. + # + # Default to nil. + attr_accessor :proxyuserpwd + attr_accessor :inject_format @@ -155,6 +165,8 @@ def initialize @key_file = nil @timeout = 0 @params_encoding = nil + @proxy = nil + @proxyuserpwd = nil @debugging = false @inject_format = false @force_ending_format = false From 7731f66916dd9c6f8f60c7260d8840f78bad0b55 Mon Sep 17 00:00:00 2001 From: AbeCole Date: Thu, 25 May 2023 20:49:21 +0100 Subject: [PATCH 2/3] Added temporary debug to check config options --- lib/docraptor/api_client.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/docraptor/api_client.rb b/lib/docraptor/api_client.rb index 89c4626..7862f85 100644 --- a/lib/docraptor/api_client.rb +++ b/lib/docraptor/api_client.rb @@ -115,6 +115,7 @@ def build_request(http_method, path, opts = {}) :proxyuserpwd => @config.proxyuserpwd, :followlocation => follow_location } + @config.logger.debug "req_opts\n#{req_opts}\n~END~\n" # set custom cert, if provided req_opts[:cainfo] = @config.ssl_ca_cert if @config.ssl_ca_cert From f09b78b49a5f9d709b2eb8af07bc3f9f07c2eba5 Mon Sep 17 00:00:00 2001 From: AbeCole Date: Thu, 25 May 2023 21:10:53 +0100 Subject: [PATCH 3/3] Temporary debug removed --- lib/docraptor/api_client.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/docraptor/api_client.rb b/lib/docraptor/api_client.rb index 7862f85..89c4626 100644 --- a/lib/docraptor/api_client.rb +++ b/lib/docraptor/api_client.rb @@ -115,7 +115,6 @@ def build_request(http_method, path, opts = {}) :proxyuserpwd => @config.proxyuserpwd, :followlocation => follow_location } - @config.logger.debug "req_opts\n#{req_opts}\n~END~\n" # set custom cert, if provided req_opts[:cainfo] = @config.ssl_ca_cert if @config.ssl_ca_cert