Module: Savon::HTTPITransportOptions
- Included in:
- GlobalOptions
- Defined in:
- lib/savon/options.rb
Overview
Options that belong to HTTPI's transport layer.
They still work with the default HTTPI transport. With transport: :faraday,
Savon does not translate them because Faraday exposes its own setup API for
proxy, timeout, TLS, auth, redirects, and adapter choices.
Constant Summary collapse
- TRANSPORT_DEFAULTS =
{ adapter: nil, follow_redirects: false }.freeze
- FARADAY_INCOMPATIBLE_GLOBALS =
These are rejected for
transport: :faradayonce the caller has set a non-default value. The error points to the matching Faraday setup. FaradayMigrationHint::OPTIONS
Instance Method Summary collapse
-
#adapter(adapter) ⇒ Object
Instruct Savon which HTTPI adapter to use instead of the default.
-
#basic_auth(*credentials) ⇒ Object
HTTP basic auth credentials.
-
#digest_auth(*credentials) ⇒ Object
HTTP digest auth credentials.
-
#follow_redirects(follow_redirects) ⇒ Object
Instruct requests to follow HTTP redirects.
-
#ntlm(*credentials) ⇒ Object
NTLM auth credentials.
-
#open_timeout(open_timeout) ⇒ Object
Open timeout in seconds.
-
#proxy(proxy) ⇒ Object
Proxy server to use for all requests.
-
#read_timeout(read_timeout) ⇒ Object
Read timeout in seconds.
-
#ssl_ca_cert(cert) ⇒ Object
Sets the CA cert to use.
-
#ssl_ca_cert_file(file) ⇒ Object
Sets the CA cert file to use.
-
#ssl_ca_cert_path(path) ⇒ Object
Sets the CA cert path.
-
#ssl_cert(cert) ⇒ Object
Sets the cert to use.
-
#ssl_cert_file(file) ⇒ Object
Sets the cert file to use.
-
#ssl_cert_key(key) ⇒ Object
Sets the cert key to use.
-
#ssl_cert_key_file(file) ⇒ Object
Sets the cert key file to use.
-
#ssl_cert_key_password(password) ⇒ Object
Sets the cert key password to use.
-
#ssl_cert_store(store) ⇒ Object
Sets the SSL cert store.
-
#ssl_ciphers(ciphers) ⇒ Object
Sets the SSL ciphers to use.
-
#ssl_max_version(version) ⇒ Object
Specifies the maximum SSL version to use.
-
#ssl_min_version(version) ⇒ Object
Specifies the minimum SSL version to use.
-
#ssl_verify_mode(verify_mode) ⇒ Object
Whether and how to verify the SSL connection.
-
#ssl_version(version) ⇒ Object
Specifies the SSL version to use.
-
#validate_transport! ⇒ Object
Runs after all global options have been assigned, including options set in the client block.
-
#write_timeout(write_timeout) ⇒ Object
Write timeout in seconds.
Instance Method Details
#adapter(adapter) ⇒ Object
Instruct Savon which HTTPI adapter to use instead of the default.
228 229 230 |
# File 'lib/savon/options.rb', line 228 def adapter(adapter) @options[:adapter] = adapter end |
#basic_auth(*credentials) ⇒ Object
HTTP basic auth credentials.
208 209 210 |
# File 'lib/savon/options.rb', line 208 def basic_auth(*credentials) @options[:basic_auth] = credentials.flatten end |
#digest_auth(*credentials) ⇒ Object
HTTP digest auth credentials.
213 214 215 |
# File 'lib/savon/options.rb', line 213 def digest_auth(*credentials) @options[:digest_auth] = credentials.flatten end |
#follow_redirects(follow_redirects) ⇒ Object
Instruct requests to follow HTTP redirects.
223 224 225 |
# File 'lib/savon/options.rb', line 223 def follow_redirects(follow_redirects) @options[:follow_redirects] = follow_redirects end |
#ntlm(*credentials) ⇒ Object
NTLM auth credentials.
218 219 220 |
# File 'lib/savon/options.rb', line 218 def ntlm(*credentials) @options[:ntlm] = credentials.flatten end |
#open_timeout(open_timeout) ⇒ Object
Open timeout in seconds.
123 124 125 |
# File 'lib/savon/options.rb', line 123 def open_timeout(open_timeout) @options[:open_timeout] = open_timeout end |
#proxy(proxy) ⇒ Object
Proxy server to use for all requests.
118 119 120 |
# File 'lib/savon/options.rb', line 118 def proxy(proxy) @options[:proxy] = proxy unless proxy.nil? end |
#read_timeout(read_timeout) ⇒ Object
Read timeout in seconds.
128 129 130 |
# File 'lib/savon/options.rb', line 128 def read_timeout(read_timeout) @options[:read_timeout] = read_timeout end |
#ssl_ca_cert(cert) ⇒ Object
Sets the CA cert to use.
188 189 190 |
# File 'lib/savon/options.rb', line 188 def ssl_ca_cert(cert) @options[:ssl_ca_cert] = cert end |
#ssl_ca_cert_file(file) ⇒ Object
Sets the CA cert file to use.
183 184 185 |
# File 'lib/savon/options.rb', line 183 def ssl_ca_cert_file(file) @options[:ssl_ca_cert_file] = file end |
#ssl_ca_cert_path(path) ⇒ Object
Sets the CA cert path.
198 199 200 |
# File 'lib/savon/options.rb', line 198 def ssl_ca_cert_path(path) @options[:ssl_ca_cert_path] = path end |
#ssl_cert(cert) ⇒ Object
Sets the cert to use.
178 179 180 |
# File 'lib/savon/options.rb', line 178 def ssl_cert(cert) @options[:ssl_cert] = cert end |
#ssl_cert_file(file) ⇒ Object
Sets the cert file to use.
173 174 175 |
# File 'lib/savon/options.rb', line 173 def ssl_cert_file(file) @options[:ssl_cert_file] = file end |
#ssl_cert_key(key) ⇒ Object
Sets the cert key to use.
163 164 165 |
# File 'lib/savon/options.rb', line 163 def ssl_cert_key(key) @options[:ssl_cert_key] = key end |
#ssl_cert_key_file(file) ⇒ Object
Sets the cert key file to use.
158 159 160 |
# File 'lib/savon/options.rb', line 158 def ssl_cert_key_file(file) @options[:ssl_cert_key_file] = file end |
#ssl_cert_key_password(password) ⇒ Object
Sets the cert key password to use.
168 169 170 |
# File 'lib/savon/options.rb', line 168 def ssl_cert_key_password(password) @options[:ssl_cert_key_password] = password end |
#ssl_cert_store(store) ⇒ Object
Sets the SSL cert store.
203 204 205 |
# File 'lib/savon/options.rb', line 203 def ssl_cert_store(store) @options[:ssl_cert_store] = store end |
#ssl_ciphers(ciphers) ⇒ Object
Sets the SSL ciphers to use.
193 194 195 |
# File 'lib/savon/options.rb', line 193 def ssl_ciphers(ciphers) @options[:ssl_ciphers] = ciphers end |
#ssl_max_version(version) ⇒ Object
Specifies the maximum SSL version to use.
148 149 150 |
# File 'lib/savon/options.rb', line 148 def ssl_max_version(version) @options[:ssl_max_version] = version end |
#ssl_min_version(version) ⇒ Object
Specifies the minimum SSL version to use.
143 144 145 |
# File 'lib/savon/options.rb', line 143 def ssl_min_version(version) @options[:ssl_min_version] = version end |
#ssl_verify_mode(verify_mode) ⇒ Object
Whether and how to verify the SSL connection.
153 154 155 |
# File 'lib/savon/options.rb', line 153 def ssl_verify_mode(verify_mode) @options[:ssl_verify_mode] = verify_mode end |
#ssl_version(version) ⇒ Object
Specifies the SSL version to use.
138 139 140 |
# File 'lib/savon/options.rb', line 138 def ssl_version(version) @options[:ssl_version] = version end |
#validate_transport! ⇒ Object
Runs after all global options have been assigned, including options set in the client block. Reports every HTTPI-only option in one error so callers can move their transport setup to Faraday in one pass.
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
# File 'lib/savon/options.rb', line 95 def validate_transport! return unless self[:transport] == :faraday unless faraday_loaded? raise InitializationError, "transport: :faraday requires the faraday gem.\n" \ "Add to your Gemfile: gem 'faraday'" end violations = FARADAY_INCOMPATIBLE_GLOBALS.filter_map { |option| next unless include?(option) next if default_transport_option?(option) FaradayMigrationHint.new(option, self[option]). } return if violations.empty? raise InitializationError, "The following options are not supported with transport: :faraday:\n#{violations.join("\n")}" end |
#write_timeout(write_timeout) ⇒ Object
Write timeout in seconds.
133 134 135 |
# File 'lib/savon/options.rb', line 133 def write_timeout(write_timeout) @options[:write_timeout] = write_timeout end |