Module: DeepL::Utils::HTTPClientBuilder
- Extended by:
- HTTPClientBuilder
- Included in:
- HTTPClientBuilder
- Defined in:
- lib/deepl/utils/http_client_builder.rb
Constant Summary collapse
- PROXY_SCHEMES =
%w[http https].freeze
Instance Method Summary collapse
-
#build(host, options) ⇒ Net::HTTP
Builds an unstarted Net::HTTP client for
hostconfigured withoptions. -
#disable_lenient_defaults(http) ⇒ Object
Net::HTTP would re-send idempotent requests once on its own, outside max_retries, and would return a body shorter than its Content-Length as complete (+ignore_eof+, net-http 0.3+).
Instance Method Details
#build(host, options) ⇒ Net::HTTP
Builds an unstarted Net::HTTP client for host configured with options. Net::HTTP does
not retry on its own (+max_retries+ 0): only the library's retries apply.
20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/deepl/utils/http_client_builder.rb', line 20 def build(host, ) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength uri = URI(host) http = Net::HTTP.new(uri.host, uri.port, *proxy_arguments(.proxy, uri)) http.use_ssl = uri.scheme == 'https' disable_lenient_defaults(http) http.verify_mode = OpenSSL::SSL::VERIFY_NONE unless .enable_ssl_verification http.ca_file = .cert_path if .cert_path http.open_timeout = .open_timeout unless .open_timeout.nil? http.read_timeout = .read_timeout unless .read_timeout.nil? http.write_timeout = .write_timeout unless .write_timeout.nil? http.ssl_timeout = .ssl_timeout unless .ssl_timeout.nil? http end |
#disable_lenient_defaults(http) ⇒ Object
Net::HTTP would re-send idempotent requests once on its own, outside max_retries, and would return a body shorter than its Content-Length as complete (+ignore_eof+, net-http 0.3+).
37 38 39 40 41 |
# File 'lib/deepl/utils/http_client_builder.rb', line 37 def disable_lenient_defaults(http) http.max_retries = 0 http.ignore_eof = false if http.respond_to?(:ignore_eof=) http end |