aws-sdk-core 3.100.0 → 3.130.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +1294 -0
- data/LICENSE.txt +202 -0
- data/VERSION +1 -1
- data/lib/aws-defaults/default_configuration.rb +153 -0
- data/lib/aws-defaults/defaults_mode_config_resolver.rb +107 -0
- data/lib/aws-defaults.rb +3 -0
- data/lib/aws-sdk-core/arn.rb +15 -0
- data/lib/aws-sdk-core/arn_parser.rb +2 -0
- data/lib/aws-sdk-core/assume_role_credentials.rb +21 -0
- data/lib/aws-sdk-core/assume_role_web_identity_credentials.rb +9 -1
- data/lib/aws-sdk-core/async_client_stubs.rb +2 -0
- data/lib/aws-sdk-core/binary/decode_handler.rb +2 -0
- data/lib/aws-sdk-core/binary/encode_handler.rb +2 -0
- data/lib/aws-sdk-core/binary/event_builder.rb +2 -0
- data/lib/aws-sdk-core/binary/event_parser.rb +2 -0
- data/lib/aws-sdk-core/binary/event_stream_decoder.rb +2 -0
- data/lib/aws-sdk-core/binary/event_stream_encoder.rb +2 -0
- data/lib/aws-sdk-core/binary.rb +2 -0
- data/lib/aws-sdk-core/client_side_monitoring/publisher.rb +2 -0
- data/lib/aws-sdk-core/client_side_monitoring/request_metrics.rb +2 -0
- data/lib/aws-sdk-core/client_stubs.rb +7 -1
- data/lib/aws-sdk-core/credential_provider.rb +2 -0
- data/lib/aws-sdk-core/credential_provider_chain.rb +23 -1
- data/lib/aws-sdk-core/credentials.rb +2 -0
- data/lib/aws-sdk-core/deprecations.rb +2 -0
- data/lib/aws-sdk-core/eager_loader.rb +2 -0
- data/lib/aws-sdk-core/ec2_metadata.rb +238 -0
- data/lib/aws-sdk-core/ecs_credentials.rb +10 -4
- data/lib/aws-sdk-core/endpoint_cache.rb +2 -0
- data/lib/aws-sdk-core/errors.rb +11 -2
- data/lib/aws-sdk-core/event_emitter.rb +2 -0
- data/lib/aws-sdk-core/ini_parser.rb +2 -0
- data/lib/aws-sdk-core/instance_profile_credentials.rb +124 -22
- data/lib/aws-sdk-core/json/builder.rb +2 -0
- data/lib/aws-sdk-core/json/error_handler.rb +2 -0
- data/lib/aws-sdk-core/json/handler.rb +2 -0
- data/lib/aws-sdk-core/json/json_engine.rb +12 -8
- data/lib/aws-sdk-core/json/oj_engine.rb +35 -6
- data/lib/aws-sdk-core/json/parser.rb +10 -0
- data/lib/aws-sdk-core/json.rb +10 -26
- data/lib/aws-sdk-core/log/formatter.rb +9 -3
- data/lib/aws-sdk-core/log/handler.rb +2 -0
- data/lib/aws-sdk-core/log/param_filter.rb +37 -12
- data/lib/aws-sdk-core/log/param_formatter.rb +2 -0
- data/lib/aws-sdk-core/pageable_response.rb +82 -32
- data/lib/aws-sdk-core/pager.rb +5 -0
- data/lib/aws-sdk-core/param_converter.rb +2 -0
- data/lib/aws-sdk-core/param_validator.rb +54 -4
- data/lib/aws-sdk-core/plugins/api_key.rb +5 -1
- data/lib/aws-sdk-core/plugins/apig_authorizer_token.rb +2 -0
- data/lib/aws-sdk-core/plugins/apig_credentials_configuration.rb +2 -0
- data/lib/aws-sdk-core/plugins/apig_user_agent.rb +2 -0
- data/lib/aws-sdk-core/plugins/checksum_algorithm.rb +340 -0
- data/lib/aws-sdk-core/plugins/client_metrics_plugin.rb +2 -0
- data/lib/aws-sdk-core/plugins/client_metrics_send_plugin.rb +2 -0
- data/lib/aws-sdk-core/plugins/credentials_configuration.rb +26 -7
- data/lib/aws-sdk-core/plugins/defaults_mode.rb +40 -0
- data/lib/aws-sdk-core/plugins/endpoint_discovery.rb +2 -0
- data/lib/aws-sdk-core/plugins/endpoint_pattern.rb +8 -6
- data/lib/aws-sdk-core/plugins/event_stream_configuration.rb +2 -0
- data/lib/aws-sdk-core/plugins/global_configuration.rb +2 -0
- data/lib/aws-sdk-core/plugins/helpful_socket_errors.rb +2 -0
- data/lib/aws-sdk-core/plugins/http_checksum.rb +10 -1
- data/lib/aws-sdk-core/plugins/idempotency_token.rb +2 -0
- data/lib/aws-sdk-core/plugins/invocation_id.rb +2 -0
- data/lib/aws-sdk-core/plugins/jsonvalue_converter.rb +2 -0
- data/lib/aws-sdk-core/plugins/logging.rb +2 -0
- data/lib/aws-sdk-core/plugins/param_converter.rb +2 -0
- data/lib/aws-sdk-core/plugins/param_validator.rb +2 -0
- data/lib/aws-sdk-core/plugins/protocols/api_gateway.rb +19 -0
- data/lib/aws-sdk-core/plugins/protocols/ec2.rb +2 -0
- data/lib/aws-sdk-core/plugins/protocols/json_rpc.rb +2 -0
- data/lib/aws-sdk-core/plugins/protocols/query.rb +2 -0
- data/lib/aws-sdk-core/plugins/protocols/rest_json.rb +18 -1
- data/lib/aws-sdk-core/plugins/protocols/rest_xml.rb +2 -0
- data/lib/aws-sdk-core/plugins/recursion_detection.rb +27 -0
- data/lib/aws-sdk-core/plugins/regional_endpoint.rb +50 -2
- data/lib/aws-sdk-core/plugins/response_paging.rb +3 -1
- data/lib/aws-sdk-core/plugins/retries/client_rate_limiter.rb +2 -0
- data/lib/aws-sdk-core/plugins/retries/clock_skew.rb +2 -0
- data/lib/aws-sdk-core/plugins/retries/error_inspector.rb +7 -3
- data/lib/aws-sdk-core/plugins/retries/retry_quota.rb +2 -0
- data/lib/aws-sdk-core/plugins/retry_errors.rb +15 -6
- data/lib/aws-sdk-core/plugins/signature_v2.rb +2 -0
- data/lib/aws-sdk-core/plugins/signature_v4.rb +17 -24
- data/lib/aws-sdk-core/plugins/stub_responses.rb +9 -1
- data/lib/aws-sdk-core/plugins/transfer_encoding.rb +2 -0
- data/lib/aws-sdk-core/plugins/user_agent.rb +2 -0
- data/lib/aws-sdk-core/process_credentials.rb +8 -6
- data/lib/aws-sdk-core/query/ec2_param_builder.rb +2 -0
- data/lib/aws-sdk-core/query/handler.rb +2 -0
- data/lib/aws-sdk-core/query/param.rb +2 -0
- data/lib/aws-sdk-core/query/param_builder.rb +2 -0
- data/lib/aws-sdk-core/query/param_list.rb +2 -0
- data/lib/aws-sdk-core/query.rb +2 -0
- data/lib/aws-sdk-core/refreshing_credentials.rb +42 -11
- data/lib/aws-sdk-core/resources/collection.rb +2 -0
- data/lib/aws-sdk-core/rest/handler.rb +2 -0
- data/lib/aws-sdk-core/rest/request/body.rb +21 -1
- data/lib/aws-sdk-core/rest/request/builder.rb +2 -0
- data/lib/aws-sdk-core/rest/request/endpoint.rb +2 -0
- data/lib/aws-sdk-core/rest/request/headers.rb +20 -6
- data/lib/aws-sdk-core/rest/request/querystring_builder.rb +2 -0
- data/lib/aws-sdk-core/rest/response/body.rb +2 -0
- data/lib/aws-sdk-core/rest/response/headers.rb +6 -3
- data/lib/aws-sdk-core/rest/response/parser.rb +2 -0
- data/lib/aws-sdk-core/rest/response/status_code.rb +2 -0
- data/lib/aws-sdk-core/rest.rb +2 -0
- data/lib/aws-sdk-core/shared_config.rb +62 -8
- data/lib/aws-sdk-core/shared_credentials.rb +9 -1
- data/lib/aws-sdk-core/sso_credentials.rb +137 -0
- data/lib/aws-sdk-core/structure.rb +13 -2
- data/lib/aws-sdk-core/stubbing/data_applicator.rb +2 -0
- data/lib/aws-sdk-core/stubbing/empty_stub.rb +2 -0
- data/lib/aws-sdk-core/stubbing/protocols/api_gateway.rb +2 -0
- data/lib/aws-sdk-core/stubbing/protocols/ec2.rb +2 -0
- data/lib/aws-sdk-core/stubbing/protocols/json.rb +3 -1
- data/lib/aws-sdk-core/stubbing/protocols/query.rb +2 -0
- data/lib/aws-sdk-core/stubbing/protocols/rest.rb +3 -1
- data/lib/aws-sdk-core/stubbing/protocols/rest_json.rb +3 -1
- data/lib/aws-sdk-core/stubbing/protocols/rest_xml.rb +2 -2
- data/lib/aws-sdk-core/stubbing/stub_data.rb +2 -0
- data/lib/aws-sdk-core/stubbing/xml_error.rb +2 -0
- data/lib/aws-sdk-core/type_builder.rb +2 -0
- data/lib/aws-sdk-core/util.rb +2 -0
- data/lib/aws-sdk-core/waiters/errors.rb +2 -0
- data/lib/aws-sdk-core/waiters/poller.rb +2 -0
- data/lib/aws-sdk-core/waiters/waiter.rb +2 -0
- data/lib/aws-sdk-core/waiters.rb +2 -0
- data/lib/aws-sdk-core/xml/builder.rb +4 -2
- data/lib/aws-sdk-core/xml/default_list.rb +2 -0
- data/lib/aws-sdk-core/xml/default_map.rb +2 -0
- data/lib/aws-sdk-core/xml/doc_builder.rb +8 -1
- data/lib/aws-sdk-core/xml/error_handler.rb +2 -0
- data/lib/aws-sdk-core/xml/parser/engines/libxml.rb +2 -0
- data/lib/aws-sdk-core/xml/parser/engines/nokogiri.rb +2 -0
- data/lib/aws-sdk-core/xml/parser/engines/oga.rb +2 -0
- data/lib/aws-sdk-core/xml/parser/engines/ox.rb +3 -1
- data/lib/aws-sdk-core/xml/parser/engines/rexml.rb +2 -0
- data/lib/aws-sdk-core/xml/parser/frame.rb +25 -0
- data/lib/aws-sdk-core/xml/parser/parsing_error.rb +2 -0
- data/lib/aws-sdk-core/xml/parser/stack.rb +2 -0
- data/lib/aws-sdk-core/xml/parser.rb +7 -0
- data/lib/aws-sdk-core/xml.rb +2 -0
- data/lib/aws-sdk-core.rb +15 -3
- data/lib/aws-sdk-sso/client.rb +570 -0
- data/lib/aws-sdk-sso/client_api.rb +190 -0
- data/lib/aws-sdk-sso/customizations.rb +1 -0
- data/lib/aws-sdk-sso/errors.rb +102 -0
- data/lib/aws-sdk-sso/resource.rb +26 -0
- data/lib/aws-sdk-sso/types.rb +352 -0
- data/lib/aws-sdk-sso.rb +55 -0
- data/lib/aws-sdk-sts/client.rb +538 -435
- data/lib/aws-sdk-sts/client_api.rb +9 -1
- data/lib/aws-sdk-sts/customizations.rb +2 -0
- data/lib/aws-sdk-sts/errors.rb +3 -1
- data/lib/aws-sdk-sts/plugins/sts_regional_endpoints.rb +7 -1
- data/lib/aws-sdk-sts/presigner.rb +9 -1
- data/lib/aws-sdk-sts/resource.rb +3 -1
- data/lib/aws-sdk-sts/types.rb +360 -191
- data/lib/aws-sdk-sts.rb +10 -3
- data/lib/seahorse/client/async_base.rb +2 -0
- data/lib/seahorse/client/async_response.rb +2 -0
- data/lib/seahorse/client/base.rb +3 -0
- data/lib/seahorse/client/block_io.rb +5 -2
- data/lib/seahorse/client/configuration.rb +6 -0
- data/lib/seahorse/client/events.rb +2 -0
- data/lib/seahorse/client/h2/connection.rb +17 -13
- data/lib/seahorse/client/h2/handler.rb +6 -5
- data/lib/seahorse/client/handler.rb +2 -0
- data/lib/seahorse/client/handler_builder.rb +2 -0
- data/lib/seahorse/client/handler_list.rb +2 -0
- data/lib/seahorse/client/handler_list_entry.rb +2 -0
- data/lib/seahorse/client/http/async_response.rb +2 -0
- data/lib/seahorse/client/http/headers.rb +2 -0
- data/lib/seahorse/client/http/request.rb +2 -0
- data/lib/seahorse/client/http/response.rb +3 -1
- data/lib/seahorse/client/logging/formatter.rb +2 -0
- data/lib/seahorse/client/logging/handler.rb +2 -0
- data/lib/seahorse/client/managed_file.rb +2 -0
- data/lib/seahorse/client/net_http/connection_pool.rb +12 -4
- data/lib/seahorse/client/net_http/handler.rb +19 -8
- data/lib/seahorse/client/net_http/patches.rb +15 -84
- data/lib/seahorse/client/networking_error.rb +2 -0
- data/lib/seahorse/client/plugin.rb +2 -0
- data/lib/seahorse/client/plugin_list.rb +2 -0
- data/lib/seahorse/client/plugins/content_length.rb +13 -5
- data/lib/seahorse/client/plugins/endpoint.rb +2 -0
- data/lib/seahorse/client/plugins/h2.rb +6 -1
- data/lib/seahorse/client/plugins/logging.rb +2 -0
- data/lib/seahorse/client/plugins/net_http.rb +39 -3
- data/lib/seahorse/client/plugins/operation_methods.rb +2 -0
- data/lib/seahorse/client/plugins/raise_response_errors.rb +2 -0
- data/lib/seahorse/client/plugins/request_callback.rb +110 -0
- data/lib/seahorse/client/plugins/response_target.rb +8 -8
- data/lib/seahorse/client/request.rb +2 -0
- data/lib/seahorse/client/request_context.rb +2 -0
- data/lib/seahorse/client/response.rb +2 -0
- data/lib/seahorse/model/api.rb +2 -0
- data/lib/seahorse/model/authorizer.rb +2 -0
- data/lib/seahorse/model/operation.rb +5 -0
- data/lib/seahorse/model/shapes.rb +27 -0
- data/lib/seahorse/util.rb +8 -1
- data/lib/seahorse/version.rb +2 -0
- data/lib/seahorse.rb +3 -0
- metadata +26 -9
data/lib/aws-sdk-sts.rb
CHANGED
|
@@ -1,11 +1,18 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
# WARNING ABOUT GENERATED CODE
|
|
2
4
|
#
|
|
3
5
|
# This file is generated. See the contributing guide for more information:
|
|
4
|
-
# https://github.com/aws/aws-sdk-ruby/blob/
|
|
6
|
+
# https://github.com/aws/aws-sdk-ruby/blob/version-3/CONTRIBUTING.md
|
|
5
7
|
#
|
|
6
8
|
# WARNING ABOUT GENERATED CODE
|
|
7
9
|
|
|
8
10
|
|
|
11
|
+
unless Module.const_defined?(:Aws)
|
|
12
|
+
require 'aws-sdk-core'
|
|
13
|
+
require 'aws-sigv4'
|
|
14
|
+
end
|
|
15
|
+
|
|
9
16
|
require_relative 'aws-sdk-sts/types'
|
|
10
17
|
require_relative 'aws-sdk-sts/client_api'
|
|
11
18
|
require_relative 'aws-sdk-sts/client'
|
|
@@ -40,9 +47,9 @@ require_relative 'aws-sdk-sts/customizations'
|
|
|
40
47
|
#
|
|
41
48
|
# See {Errors} for more information.
|
|
42
49
|
#
|
|
43
|
-
#
|
|
50
|
+
# @!group service
|
|
44
51
|
module Aws::STS
|
|
45
52
|
|
|
46
|
-
GEM_VERSION = '3.
|
|
53
|
+
GEM_VERSION = '3.130.0'
|
|
47
54
|
|
|
48
55
|
end
|
data/lib/seahorse/client/base.rb
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module Seahorse
|
|
2
4
|
module Client
|
|
3
5
|
class BlockIO
|
|
4
6
|
|
|
5
|
-
def initialize(&block)
|
|
7
|
+
def initialize(headers = nil, &block)
|
|
8
|
+
@headers = headers
|
|
6
9
|
@block = block
|
|
7
10
|
@size = 0
|
|
8
11
|
end
|
|
@@ -10,7 +13,7 @@ module Seahorse
|
|
|
10
13
|
# @param [String] chunk
|
|
11
14
|
# @return [Integer]
|
|
12
15
|
def write(chunk)
|
|
13
|
-
@block.call(chunk)
|
|
16
|
+
@block.call(chunk, @headers)
|
|
14
17
|
ensure
|
|
15
18
|
chunk.bytesize.tap { |chunk_size| @size += chunk_size }
|
|
16
19
|
end
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'set'
|
|
2
4
|
|
|
3
5
|
module Seahorse
|
|
@@ -193,6 +195,10 @@ module Seahorse
|
|
|
193
195
|
@members.include?(method_name) or super
|
|
194
196
|
end
|
|
195
197
|
|
|
198
|
+
def override_config(k, v)
|
|
199
|
+
@struct[k] = v
|
|
200
|
+
end
|
|
201
|
+
|
|
196
202
|
private
|
|
197
203
|
|
|
198
204
|
def value_at(opt_name)
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
end
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
begin
|
|
4
|
+
require 'http/2'
|
|
5
|
+
rescue LoadError; end
|
|
6
6
|
require 'openssl'
|
|
7
7
|
require 'socket'
|
|
8
8
|
|
|
@@ -73,18 +73,23 @@ module Seahorse
|
|
|
73
73
|
def connect(endpoint)
|
|
74
74
|
@mutex.synchronize {
|
|
75
75
|
if @status == :ready
|
|
76
|
-
tcp, addr = _tcp_socket(endpoint)
|
|
76
|
+
tcp, addr = _tcp_socket(endpoint)
|
|
77
77
|
debug_output("opening connection to #{endpoint.host}:#{endpoint.port} ...")
|
|
78
78
|
_nonblocking_connect(tcp, addr)
|
|
79
79
|
debug_output('opened')
|
|
80
80
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
81
|
+
if endpoint.scheme == 'https'
|
|
82
|
+
@socket = OpenSSL::SSL::SSLSocket.new(tcp, _tls_context)
|
|
83
|
+
@socket.sync_close = true
|
|
84
|
+
@socket.hostname = endpoint.host
|
|
85
|
+
|
|
86
|
+
debug_output("starting TLS for #{endpoint.host}:#{endpoint.port} ...")
|
|
87
|
+
@socket.connect
|
|
88
|
+
debug_output('TLS established')
|
|
89
|
+
else
|
|
90
|
+
@socket = tcp
|
|
91
|
+
end
|
|
84
92
|
|
|
85
|
-
debug_output("starting TLS for #{endpoint.host}:#{endpoint.port} ...")
|
|
86
|
-
@socket.connect
|
|
87
|
-
debug_output('TLS established')
|
|
88
93
|
_register_h2_callbacks
|
|
89
94
|
@status = :active
|
|
90
95
|
elsif @status == :closed
|
|
@@ -243,4 +248,3 @@ module Seahorse
|
|
|
243
248
|
end
|
|
244
249
|
end
|
|
245
250
|
end
|
|
246
|
-
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module Seahorse
|
|
2
4
|
module Client
|
|
3
5
|
module Http
|
|
@@ -71,7 +73,7 @@ module Seahorse
|
|
|
71
73
|
|
|
72
74
|
# Completes the http response.
|
|
73
75
|
#
|
|
74
|
-
# @example Completing the response in a
|
|
76
|
+
# @example Completing the response in a single call
|
|
75
77
|
#
|
|
76
78
|
# http_response.signal_done(
|
|
77
79
|
# status_code: 200,
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'cgi'
|
|
2
4
|
require 'net/http'
|
|
3
5
|
require 'net/https'
|
|
@@ -32,6 +34,7 @@ module Seahorse
|
|
|
32
34
|
ssl_ca_bundle: nil,
|
|
33
35
|
ssl_ca_directory: nil,
|
|
34
36
|
ssl_ca_store: nil,
|
|
37
|
+
ssl_timeout: nil
|
|
35
38
|
}
|
|
36
39
|
|
|
37
40
|
# @api private
|
|
@@ -169,10 +172,9 @@ module Seahorse
|
|
|
169
172
|
# seconds to wait when opening an HTTP session before raising a
|
|
170
173
|
# `Timeout::Error`.
|
|
171
174
|
#
|
|
172
|
-
# @option options [
|
|
173
|
-
# number of seconds to wait for response data.
|
|
174
|
-
# safely
|
|
175
|
-
# per-request on the session yielded by {#session_for}.
|
|
175
|
+
# @option options [Float] :http_read_timeout (60) The default
|
|
176
|
+
# number of seconds to wait for response data. This value can be
|
|
177
|
+
# safely set per-request on the session yielded by {#session_for}.
|
|
176
178
|
#
|
|
177
179
|
# @option options [Float] :http_idle_timeout (5) The number of
|
|
178
180
|
# seconds a connection is allowed to sit idle before it is
|
|
@@ -186,6 +188,9 @@ module Seahorse
|
|
|
186
188
|
# disables this behaviour. This value can safely be set per
|
|
187
189
|
# request on the session yielded by {#session_for}.
|
|
188
190
|
#
|
|
191
|
+
# @option options [Float] :ssl_timeout (nil) Sets the SSL timeout
|
|
192
|
+
# in seconds.
|
|
193
|
+
#
|
|
189
194
|
# @option options [Boolean] :http_wire_trace (false) When `true`,
|
|
190
195
|
# HTTP debug output will be sent to the `:logger`.
|
|
191
196
|
#
|
|
@@ -247,6 +252,7 @@ module Seahorse
|
|
|
247
252
|
:ssl_ca_bundle => options[:ssl_ca_bundle],
|
|
248
253
|
:ssl_ca_directory => options[:ssl_ca_directory],
|
|
249
254
|
:ssl_ca_store => options[:ssl_ca_store],
|
|
255
|
+
:ssl_timeout => options[:ssl_timeout]
|
|
250
256
|
}
|
|
251
257
|
end
|
|
252
258
|
|
|
@@ -284,6 +290,8 @@ module Seahorse
|
|
|
284
290
|
|
|
285
291
|
if endpoint.scheme == 'https'
|
|
286
292
|
http.use_ssl = true
|
|
293
|
+
http.ssl_timeout = ssl_timeout
|
|
294
|
+
|
|
287
295
|
if ssl_verify_peer?
|
|
288
296
|
http.verify_mode = OpenSSL::SSL::VERIFY_PEER
|
|
289
297
|
http.ca_file = ssl_ca_bundle if ssl_ca_bundle
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'net/https'
|
|
2
4
|
require 'openssl'
|
|
3
5
|
|
|
@@ -23,7 +25,8 @@ module Seahorse
|
|
|
23
25
|
SocketError, EOFError, IOError, Timeout::Error,
|
|
24
26
|
Errno::ECONNABORTED, Errno::ECONNRESET, Errno::EPIPE,
|
|
25
27
|
Errno::EINVAL, Errno::ETIMEDOUT, OpenSSL::SSL::SSLError,
|
|
26
|
-
Errno::EHOSTUNREACH, Errno::ECONNREFUSED
|
|
28
|
+
Errno::EHOSTUNREACH, Errno::ECONNREFUSED,
|
|
29
|
+
Net::HTTPFatalError # for proxy connection failures
|
|
27
30
|
]
|
|
28
31
|
|
|
29
32
|
# does not exist in Ruby 1.9.3
|
|
@@ -71,8 +74,9 @@ module Seahorse
|
|
|
71
74
|
# @return [void]
|
|
72
75
|
def transmit(config, req, resp)
|
|
73
76
|
session(config, req) do |http|
|
|
77
|
+
# Monkey patch default content-type set by Net::HTTP
|
|
78
|
+
Thread.current[:net_http_skip_default_content_type] = true
|
|
74
79
|
http.request(build_net_request(req)) do |net_resp|
|
|
75
|
-
|
|
76
80
|
status_code = net_resp.code.to_i
|
|
77
81
|
headers = extract_headers(net_resp)
|
|
78
82
|
|
|
@@ -93,6 +97,9 @@ module Seahorse
|
|
|
93
97
|
rescue => error
|
|
94
98
|
# not retryable
|
|
95
99
|
resp.signal_error(error)
|
|
100
|
+
ensure
|
|
101
|
+
# ensure we turn off monkey patch in case of error
|
|
102
|
+
Thread.current[:net_http_skip_default_content_type] = nil
|
|
96
103
|
end
|
|
97
104
|
|
|
98
105
|
def complete_response(req, resp, bytes_received)
|
|
@@ -144,7 +151,12 @@ module Seahorse
|
|
|
144
151
|
def build_net_request(request)
|
|
145
152
|
request_class = net_http_request_class(request)
|
|
146
153
|
req = request_class.new(request.endpoint.request_uri, headers(request))
|
|
147
|
-
|
|
154
|
+
# Net::HTTP adds a default Content-Type when a body is present.
|
|
155
|
+
# Set the body stream when it has an unknown size or when it is > 0.
|
|
156
|
+
if !request.body.respond_to?(:size) ||
|
|
157
|
+
(request.body.respond_to?(:size) && request.body.size > 0)
|
|
158
|
+
req.body_stream = request.body
|
|
159
|
+
end
|
|
148
160
|
req
|
|
149
161
|
end
|
|
150
162
|
|
|
@@ -163,14 +175,13 @@ module Seahorse
|
|
|
163
175
|
# @return [Hash] Returns a vanilla hash of headers to send with the
|
|
164
176
|
# HTTP request.
|
|
165
177
|
def headers(request)
|
|
166
|
-
# Net::HTTP adds default
|
|
167
|
-
#
|
|
168
|
-
# this.
|
|
178
|
+
# Net::HTTP adds a default header for accept-encoding (2.0.0+).
|
|
179
|
+
# Setting a default empty value defeats this.
|
|
169
180
|
#
|
|
170
|
-
# Removing
|
|
181
|
+
# Removing this is necessary for most services to not break request
|
|
171
182
|
# signatures as well as dynamodb crc32 checks (these fail if the
|
|
172
183
|
# response is gzipped).
|
|
173
|
-
headers = { '
|
|
184
|
+
headers = { 'accept-encoding' => '' }
|
|
174
185
|
request.headers.each_pair do |key, value|
|
|
175
186
|
headers[key] = value
|
|
176
187
|
end
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'net/http'
|
|
2
4
|
|
|
3
5
|
module Seahorse
|
|
@@ -9,97 +11,26 @@ module Seahorse
|
|
|
9
11
|
module Patches
|
|
10
12
|
|
|
11
13
|
def self.apply!
|
|
14
|
+
Net::HTTPGenericRequest.prepend(PatchDefaultContentType)
|
|
12
15
|
return unless RUBY_VERSION < '2.5'
|
|
13
|
-
if RUBY_VERSION >= '2.3'
|
|
14
|
-
Net::HTTP::IDEMPOTENT_METHODS_.clear
|
|
15
|
-
return
|
|
16
|
-
end
|
|
17
|
-
# no further patches needed for above versions
|
|
18
16
|
|
|
19
|
-
|
|
20
|
-
Net::HTTP.send(:include, Ruby_2)
|
|
21
|
-
Net::HTTP::IDEMPOTENT_METHODS_.clear
|
|
22
|
-
elsif RUBY_VERSION >= '1.9.3'
|
|
23
|
-
Net::HTTP.send(:include, Ruby_1_9_3)
|
|
24
|
-
end
|
|
25
|
-
Net::HTTP.send(:alias_method, :old_transport_request, :transport_request)
|
|
26
|
-
Net::HTTP.send(:alias_method, :transport_request, :new_transport_request)
|
|
17
|
+
Net::HTTP::IDEMPOTENT_METHODS_.clear
|
|
27
18
|
end
|
|
28
19
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
res.uri = req.uri
|
|
42
|
-
|
|
43
|
-
res
|
|
44
|
-
}
|
|
45
|
-
res.reading_body(@socket, req.response_body_permitted?) {
|
|
46
|
-
yield res if block_given?
|
|
47
|
-
}
|
|
48
|
-
rescue Net::OpenTimeout
|
|
49
|
-
raise
|
|
50
|
-
rescue Net::ReadTimeout, IOError, EOFError,
|
|
51
|
-
Errno::ECONNRESET, Errno::ECONNABORTED, Errno::EPIPE,
|
|
52
|
-
# avoid a dependency on OpenSSL
|
|
53
|
-
defined?(OpenSSL::SSL) ? OpenSSL::SSL::SSLError : IOError,
|
|
54
|
-
Timeout::Error => exception
|
|
55
|
-
if count == 0 && Net::HTTP::IDEMPOTENT_METHODS_.include?(req.method)
|
|
56
|
-
count += 1
|
|
57
|
-
@socket.close if @socket and not @socket.closed?
|
|
58
|
-
D "Conn close because of error #{exception}, and retry"
|
|
59
|
-
if req.body_stream
|
|
60
|
-
if req.body_stream.respond_to?(:rewind)
|
|
61
|
-
req.body_stream.rewind
|
|
62
|
-
else
|
|
63
|
-
raise
|
|
64
|
-
end
|
|
65
|
-
end
|
|
66
|
-
retry
|
|
67
|
-
end
|
|
68
|
-
D "Conn close because of error #{exception}"
|
|
69
|
-
@socket.close if @socket and not @socket.closed?
|
|
70
|
-
raise
|
|
71
|
-
end
|
|
72
|
-
|
|
73
|
-
end_transport req, res
|
|
74
|
-
res
|
|
75
|
-
rescue => exception
|
|
76
|
-
D "Conn close because of error #{exception}"
|
|
77
|
-
@socket.close if @socket and not @socket.closed?
|
|
78
|
-
raise exception
|
|
20
|
+
# For requests with bodys, Net::HTTP sets a default content type of:
|
|
21
|
+
# 'application/x-www-form-urlencoded'
|
|
22
|
+
# There are cases where we should not send content type at all.
|
|
23
|
+
# Even when no body is supplied, Net::HTTP uses a default empty body
|
|
24
|
+
# and sets it anyway. This patch disables the behavior when a Thread
|
|
25
|
+
# local variable is set.
|
|
26
|
+
module PatchDefaultContentType
|
|
27
|
+
def supply_default_content_type
|
|
28
|
+
return if Thread.current[:net_http_skip_default_content_type]
|
|
29
|
+
|
|
30
|
+
super
|
|
79
31
|
end
|
|
80
32
|
end
|
|
81
33
|
|
|
82
|
-
module Ruby_1_9_3
|
|
83
|
-
def new_transport_request(req)
|
|
84
|
-
begin_transport req
|
|
85
|
-
res = catch(:response) {
|
|
86
|
-
req.exec @socket, @curr_http_version, edit_path(req.path)
|
|
87
|
-
begin
|
|
88
|
-
res = Net::HTTPResponse.read_new(@socket)
|
|
89
|
-
end while res.kind_of?(Net::HTTPContinue)
|
|
90
|
-
res
|
|
91
|
-
}
|
|
92
|
-
res.reading_body(@socket, req.response_body_permitted?) {
|
|
93
|
-
yield res if block_given?
|
|
94
|
-
}
|
|
95
|
-
end_transport req, res
|
|
96
|
-
res
|
|
97
|
-
rescue => exception
|
|
98
|
-
D "Conn close because of error #{exception}"
|
|
99
|
-
@socket.close if @socket and not @socket.closed?
|
|
100
|
-
raise exception
|
|
101
|
-
end
|
|
102
|
-
end
|
|
103
34
|
end
|
|
104
35
|
end
|
|
105
36
|
end
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module Seahorse
|
|
2
4
|
module Client
|
|
3
5
|
module Plugins
|
|
@@ -5,16 +7,22 @@ module Seahorse
|
|
|
5
7
|
|
|
6
8
|
# @api private
|
|
7
9
|
class Handler < Client::Handler
|
|
10
|
+
# https://github.com/ruby/net-http/blob/master/lib/net/http/requests.rb
|
|
11
|
+
# Methods without body are forwards compatible, because content-length
|
|
12
|
+
# may be set for requests without body but is technically incorrect.
|
|
13
|
+
METHODS_WITHOUT_BODY = Set.new(
|
|
14
|
+
%w[GET HEAD DELETE OPTIONS TRACE COPY MOVE]
|
|
15
|
+
)
|
|
8
16
|
|
|
9
17
|
def call(context)
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
18
|
+
body = context.http_request.body
|
|
19
|
+
method = context.http_request.http_method
|
|
20
|
+
# We use Net::HTTP with body_stream which doesn't do this by default
|
|
21
|
+
if body.respond_to?(:size) && !METHODS_WITHOUT_BODY.include?(method)
|
|
22
|
+
context.http_request.headers['Content-Length'] = body.size
|
|
14
23
|
end
|
|
15
24
|
@handler.call(context)
|
|
16
25
|
end
|
|
17
|
-
|
|
18
26
|
end
|
|
19
27
|
|
|
20
28
|
handler(Handler, step: :sign, priority: 0)
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'seahorse/client/h2/handler'
|
|
2
4
|
|
|
3
5
|
module Seahorse
|
|
@@ -26,11 +28,14 @@ Defaults to `true`, raises errors if exist when #wait or #join! is called upon a
|
|
|
26
28
|
DOCS
|
|
27
29
|
|
|
28
30
|
# SSL Context
|
|
29
|
-
option(:ssl_ca_bundle, default: nil, doc_type: String, docstring: <<-DOCS)
|
|
31
|
+
option(:ssl_ca_bundle, default: nil, doc_type: String, docstring: <<-DOCS) do |cfg|
|
|
30
32
|
Full path to the SSL certificate authority bundle file that should be used when
|
|
31
33
|
verifying peer certificates. If you do not pass `:ssl_ca_directory` or `:ssl_ca_bundle`
|
|
32
34
|
the system default will be used if available.
|
|
33
35
|
DOCS
|
|
36
|
+
ENV['AWS_CA_BUNDLE'] ||
|
|
37
|
+
Aws.shared_config.ca_bundle(profile: cfg.profile) if cfg.respond_to?(:profile)
|
|
38
|
+
end
|
|
34
39
|
|
|
35
40
|
option(:ssl_ca_directory, default: nil, doc_type: String, docstring: <<-DOCS)
|
|
36
41
|
Full path of the directory that contains the unbundled SSL certificate authority
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'seahorse/client/net_http/handler'
|
|
2
4
|
|
|
3
5
|
module Seahorse
|
|
@@ -7,9 +9,13 @@ module Seahorse
|
|
|
7
9
|
|
|
8
10
|
option(:http_proxy, default: nil, doc_type: String, docstring: '')
|
|
9
11
|
|
|
10
|
-
option(:http_open_timeout, default: 15, doc_type: Integer, docstring: '')
|
|
12
|
+
option(:http_open_timeout, default: 15, doc_type: Integer, docstring: '') do |cfg|
|
|
13
|
+
resolve_http_open_timeout(cfg)
|
|
14
|
+
end
|
|
11
15
|
|
|
12
|
-
option(:http_read_timeout, default: 60, doc_type: Integer, docstring: '')
|
|
16
|
+
option(:http_read_timeout, default: 60, doc_type: Integer, docstring: '') do |cfg|
|
|
17
|
+
resolve_http_read_timeout(cfg)
|
|
18
|
+
end
|
|
13
19
|
|
|
14
20
|
option(:http_idle_timeout, default: 5, doc_type: Integer, docstring: '')
|
|
15
21
|
|
|
@@ -19,16 +25,46 @@ module Seahorse
|
|
|
19
25
|
|
|
20
26
|
option(:ssl_verify_peer, default: true, doc_type: 'Boolean', docstring: '')
|
|
21
27
|
|
|
22
|
-
option(:ssl_ca_bundle,
|
|
28
|
+
option(:ssl_ca_bundle, doc_type: String, docstring: '') do |cfg|
|
|
29
|
+
ENV['AWS_CA_BUNDLE'] ||
|
|
30
|
+
Aws.shared_config.ca_bundle(profile: cfg.profile) if cfg.respond_to?(:profile)
|
|
31
|
+
end
|
|
23
32
|
|
|
24
33
|
option(:ssl_ca_directory, default: nil, doc_type: String, docstring: '')
|
|
25
34
|
|
|
26
35
|
option(:ssl_ca_store, default: nil, doc_type: String, docstring: '')
|
|
27
36
|
|
|
37
|
+
option(:ssl_timeout, default: nil, doc_type: Float, docstring: '') do |cfg|
|
|
38
|
+
resolve_ssl_timeout(cfg)
|
|
39
|
+
end
|
|
40
|
+
|
|
28
41
|
option(:logger) # for backwards compat
|
|
29
42
|
|
|
30
43
|
handler(Client::NetHttp::Handler, step: :send)
|
|
31
44
|
|
|
45
|
+
def self.resolve_http_open_timeout(cfg)
|
|
46
|
+
default_mode_value =
|
|
47
|
+
if cfg.respond_to?(:defaults_mode_config_resolver)
|
|
48
|
+
cfg.defaults_mode_config_resolver.resolve(:http_open_timeout)
|
|
49
|
+
end
|
|
50
|
+
default_mode_value || 15
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def self.resolve_http_read_timeout(cfg)
|
|
54
|
+
default_mode_value =
|
|
55
|
+
if cfg.respond_to?(:defaults_mode_config_resolver)
|
|
56
|
+
cfg.defaults_mode_config_resolver.resolve(:http_read_timeout)
|
|
57
|
+
end
|
|
58
|
+
default_mode_value || 60
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def self.resolve_ssl_timeout(cfg)
|
|
62
|
+
default_mode_value =
|
|
63
|
+
if cfg.respond_to?(:defaults_mode_config_resolver)
|
|
64
|
+
cfg.defaults_mode_config_resolver.resolve(:ssl_timeout)
|
|
65
|
+
end
|
|
66
|
+
default_mode_value || nil
|
|
67
|
+
end
|
|
32
68
|
end
|
|
33
69
|
end
|
|
34
70
|
end
|