aws-sdk-core 3.168.4 → 3.224.1
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 +719 -0
- data/VERSION +1 -1
- data/lib/aws-defaults/default_configuration.rb +5 -6
- data/lib/aws-defaults.rb +4 -1
- data/lib/aws-sdk-core/arn.rb +1 -3
- data/lib/aws-sdk-core/assume_role_credentials.rb +13 -5
- data/lib/aws-sdk-core/assume_role_web_identity_credentials.rb +14 -7
- data/lib/aws-sdk-core/binary/decode_handler.rb +3 -9
- data/lib/aws-sdk-core/binary/encode_handler.rb +1 -1
- data/lib/aws-sdk-core/binary/event_builder.rb +34 -37
- data/lib/aws-sdk-core/binary/event_stream_decoder.rb +1 -0
- data/lib/aws-sdk-core/binary/event_stream_encoder.rb +4 -3
- data/lib/aws-sdk-core/cbor/decoder.rb +308 -0
- data/lib/aws-sdk-core/cbor/encoder.rb +243 -0
- data/lib/aws-sdk-core/cbor.rb +53 -0
- data/lib/aws-sdk-core/client_side_monitoring.rb +9 -0
- data/lib/aws-sdk-core/client_stubs.rb +33 -55
- data/lib/aws-sdk-core/credential_provider.rb +8 -1
- data/lib/aws-sdk-core/credential_provider_chain.rb +39 -11
- data/lib/aws-sdk-core/credentials.rb +19 -6
- data/lib/aws-sdk-core/ec2_metadata.rb +1 -1
- data/lib/aws-sdk-core/ecs_credentials.rb +179 -53
- data/lib/aws-sdk-core/endpoints/condition.rb +5 -0
- data/lib/aws-sdk-core/endpoints/endpoint.rb +3 -1
- data/lib/aws-sdk-core/endpoints/endpoint_rule.rb +5 -1
- data/lib/aws-sdk-core/endpoints/error_rule.rb +5 -0
- data/lib/aws-sdk-core/endpoints/function.rb +5 -0
- data/lib/aws-sdk-core/endpoints/matchers.rb +19 -18
- data/lib/aws-sdk-core/endpoints/reference.rb +5 -0
- data/lib/aws-sdk-core/endpoints/rule.rb +5 -0
- data/lib/aws-sdk-core/endpoints/rule_set.rb +5 -0
- data/lib/aws-sdk-core/endpoints/rules_provider.rb +5 -0
- data/lib/aws-sdk-core/endpoints/templater.rb +6 -0
- data/lib/aws-sdk-core/endpoints/tree_rule.rb +5 -0
- data/lib/aws-sdk-core/endpoints/url.rb +1 -0
- data/lib/aws-sdk-core/endpoints.rb +79 -19
- data/lib/aws-sdk-core/error_handler.rb +41 -0
- data/lib/aws-sdk-core/errors.rb +14 -5
- data/lib/aws-sdk-core/event_emitter.rb +0 -16
- data/lib/aws-sdk-core/ini_parser.rb +7 -0
- data/lib/aws-sdk-core/instance_profile_credentials.rb +56 -32
- data/lib/aws-sdk-core/json/builder.rb +8 -1
- data/lib/aws-sdk-core/json/error_handler.rb +30 -14
- data/lib/aws-sdk-core/json/handler.rb +13 -6
- data/lib/aws-sdk-core/json/json_engine.rb +3 -1
- data/lib/aws-sdk-core/json/oj_engine.rb +7 -1
- data/lib/aws-sdk-core/json/parser.rb +33 -3
- data/lib/aws-sdk-core/json.rb +43 -14
- data/lib/aws-sdk-core/log/formatter.rb +6 -0
- data/lib/aws-sdk-core/log/param_filter.rb +2 -2
- data/lib/aws-sdk-core/log/param_formatter.rb +7 -3
- data/lib/aws-sdk-core/log.rb +10 -0
- data/lib/aws-sdk-core/lru_cache.rb +75 -0
- data/lib/aws-sdk-core/pageable_response.rb +3 -1
- data/lib/aws-sdk-core/param_validator.rb +9 -4
- data/lib/aws-sdk-core/plugins/bearer_authorization.rb +2 -0
- data/lib/aws-sdk-core/plugins/checksum_algorithm.rb +333 -168
- data/lib/aws-sdk-core/plugins/client_metrics_plugin.rb +1 -1
- data/lib/aws-sdk-core/plugins/client_metrics_send_plugin.rb +14 -2
- data/lib/aws-sdk-core/plugins/credentials_configuration.rb +9 -3
- data/lib/aws-sdk-core/plugins/endpoint_pattern.rb +40 -32
- data/lib/aws-sdk-core/plugins/global_configuration.rb +8 -9
- data/lib/aws-sdk-core/plugins/http_checksum.rb +3 -8
- data/lib/aws-sdk-core/plugins/invocation_id.rb +1 -11
- data/lib/aws-sdk-core/plugins/logging.rb +2 -0
- data/lib/aws-sdk-core/plugins/protocols/api_gateway.rb +3 -1
- data/lib/aws-sdk-core/plugins/protocols/ec2.rb +2 -24
- data/lib/aws-sdk-core/plugins/protocols/json_rpc.rb +6 -8
- data/lib/aws-sdk-core/plugins/protocols/query.rb +4 -2
- data/lib/aws-sdk-core/plugins/protocols/rest_json.rb +3 -15
- data/lib/aws-sdk-core/plugins/protocols/rest_xml.rb +3 -0
- data/lib/aws-sdk-core/plugins/protocols/rpc_v2.rb +17 -0
- data/lib/aws-sdk-core/plugins/regional_endpoint.rb +162 -37
- data/lib/aws-sdk-core/plugins/request_compression.rb +226 -0
- data/lib/aws-sdk-core/plugins/retry_errors.rb +12 -3
- data/lib/aws-sdk-core/plugins/sign.rb +44 -17
- data/lib/aws-sdk-core/plugins/signature_v2.rb +2 -1
- data/lib/aws-sdk-core/plugins/signature_v4.rb +2 -1
- data/lib/aws-sdk-core/plugins/stub_responses.rb +53 -9
- data/lib/aws-sdk-core/plugins/telemetry.rb +75 -0
- data/lib/aws-sdk-core/plugins/transfer_encoding.rb +16 -9
- data/lib/aws-sdk-core/plugins/user_agent.rb +191 -14
- data/lib/aws-sdk-core/plugins.rb +39 -0
- data/lib/aws-sdk-core/process_credentials.rb +48 -29
- data/lib/aws-sdk-core/query/ec2_handler.rb +27 -0
- data/lib/aws-sdk-core/query/ec2_param_builder.rb +5 -7
- data/lib/aws-sdk-core/query/handler.rb +4 -4
- data/lib/aws-sdk-core/query/param_builder.rb +2 -2
- data/lib/aws-sdk-core/query.rb +2 -1
- data/lib/aws-sdk-core/refreshing_credentials.rb +12 -12
- data/lib/aws-sdk-core/resources.rb +8 -0
- data/lib/aws-sdk-core/rest/content_type_handler.rb +60 -0
- data/lib/aws-sdk-core/rest/handler.rb +3 -4
- data/lib/aws-sdk-core/rest/request/body.rb +32 -5
- data/lib/aws-sdk-core/rest/request/endpoint.rb +24 -4
- data/lib/aws-sdk-core/rest/request/headers.rb +15 -7
- data/lib/aws-sdk-core/rest/request/querystring_builder.rb +62 -36
- data/lib/aws-sdk-core/rest/response/body.rb +15 -1
- data/lib/aws-sdk-core/rest/response/header_list_parser.rb +79 -0
- data/lib/aws-sdk-core/rest/response/headers.rb +8 -3
- data/lib/aws-sdk-core/rest.rb +1 -0
- data/lib/aws-sdk-core/rpc_v2/builder.rb +62 -0
- data/lib/aws-sdk-core/rpc_v2/cbor_engine.rb +18 -0
- data/lib/aws-sdk-core/rpc_v2/content_type_handler.rb +47 -0
- data/lib/aws-sdk-core/rpc_v2/error_handler.rb +85 -0
- data/lib/aws-sdk-core/rpc_v2/handler.rb +79 -0
- data/lib/aws-sdk-core/rpc_v2/parser.rb +90 -0
- data/lib/aws-sdk-core/rpc_v2.rb +69 -0
- data/lib/aws-sdk-core/shared_config.rb +125 -39
- data/lib/aws-sdk-core/shared_credentials.rb +1 -7
- data/lib/aws-sdk-core/sso_credentials.rb +5 -2
- data/lib/aws-sdk-core/stubbing/protocols/ec2.rb +12 -11
- data/lib/aws-sdk-core/stubbing/protocols/json.rb +11 -10
- data/lib/aws-sdk-core/stubbing/protocols/query.rb +7 -6
- data/lib/aws-sdk-core/stubbing/protocols/rest.rb +2 -1
- data/lib/aws-sdk-core/stubbing/protocols/rest_json.rb +9 -8
- data/lib/aws-sdk-core/stubbing/protocols/rest_xml.rb +6 -5
- data/lib/aws-sdk-core/stubbing/protocols/rpc_v2.rb +39 -0
- data/lib/aws-sdk-core/stubbing/stub_data.rb +11 -0
- data/lib/aws-sdk-core/stubbing.rb +22 -0
- data/lib/aws-sdk-core/telemetry/base.rb +177 -0
- data/lib/aws-sdk-core/telemetry/no_op.rb +70 -0
- data/lib/aws-sdk-core/telemetry/otel.rb +235 -0
- data/lib/aws-sdk-core/telemetry/span_kind.rb +22 -0
- data/lib/aws-sdk-core/telemetry/span_status.rb +59 -0
- data/lib/aws-sdk-core/telemetry.rb +78 -0
- data/lib/aws-sdk-core/util.rb +39 -0
- data/lib/aws-sdk-core/waiters/poller.rb +12 -5
- data/lib/aws-sdk-core/xml/builder.rb +17 -9
- data/lib/aws-sdk-core/xml/error_handler.rb +32 -42
- data/lib/aws-sdk-core/xml/parser/frame.rb +4 -20
- data/lib/aws-sdk-core/xml/parser/{engines/oga.rb → oga_engine.rb} +2 -0
- data/lib/aws-sdk-core/xml/parser/stack.rb +2 -0
- data/lib/aws-sdk-core/xml/parser.rb +2 -6
- data/lib/aws-sdk-core.rb +82 -107
- data/lib/aws-sdk-sso/client.rb +185 -79
- data/lib/aws-sdk-sso/client_api.rb +7 -0
- data/lib/aws-sdk-sso/endpoint_parameters.rb +9 -6
- data/lib/aws-sdk-sso/endpoint_provider.rb +37 -96
- data/lib/aws-sdk-sso/endpoints.rb +3 -54
- data/lib/aws-sdk-sso/plugins/endpoints.rb +23 -22
- data/lib/aws-sdk-sso/types.rb +1 -0
- data/lib/aws-sdk-sso.rb +15 -11
- data/lib/aws-sdk-ssooidc/client.rb +592 -112
- data/lib/aws-sdk-ssooidc/client_api.rb +89 -1
- data/lib/aws-sdk-ssooidc/endpoint_parameters.rb +9 -6
- data/lib/aws-sdk-ssooidc/endpoint_provider.rb +37 -95
- data/lib/aws-sdk-ssooidc/endpoints.rb +3 -40
- data/lib/aws-sdk-ssooidc/errors.rb +52 -0
- data/lib/aws-sdk-ssooidc/plugins/endpoints.rb +23 -20
- data/lib/aws-sdk-ssooidc/types.rb +407 -53
- data/lib/aws-sdk-ssooidc.rb +15 -11
- data/lib/aws-sdk-sts/client.rb +516 -238
- data/lib/aws-sdk-sts/client_api.rb +48 -11
- data/lib/aws-sdk-sts/customizations.rb +5 -1
- data/lib/aws-sdk-sts/endpoint_parameters.rb +10 -9
- data/lib/aws-sdk-sts/endpoint_provider.rb +91 -213
- data/lib/aws-sdk-sts/endpoints.rb +3 -118
- data/lib/aws-sdk-sts/errors.rb +16 -0
- data/lib/aws-sdk-sts/plugins/endpoints.rb +23 -30
- data/lib/aws-sdk-sts/presigner.rb +1 -1
- data/lib/aws-sdk-sts/types.rb +217 -36
- data/lib/aws-sdk-sts.rb +15 -11
- data/lib/seahorse/client/async_base.rb +4 -5
- data/lib/seahorse/client/async_response.rb +19 -0
- data/lib/seahorse/client/base.rb +18 -21
- data/lib/seahorse/client/configuration.rb +0 -4
- data/lib/seahorse/client/h2/connection.rb +25 -31
- data/lib/seahorse/client/h2/handler.rb +14 -3
- data/lib/seahorse/client/handler.rb +1 -1
- data/lib/seahorse/client/http/response.rb +1 -1
- data/lib/seahorse/client/net_http/connection_pool.rb +13 -11
- data/lib/seahorse/client/net_http/handler.rb +21 -9
- data/lib/seahorse/client/net_http/patches.rb +1 -4
- data/lib/seahorse/client/networking_error.rb +1 -1
- data/lib/seahorse/client/plugin.rb +9 -0
- data/lib/seahorse/client/plugins/endpoint.rb +0 -1
- data/lib/seahorse/client/plugins/h2.rb +4 -4
- data/lib/seahorse/client/plugins/net_http.rb +57 -16
- data/lib/seahorse/client/plugins/request_callback.rb +31 -0
- data/lib/seahorse/client/request_context.rb +8 -1
- data/lib/seahorse/client/response.rb +8 -0
- data/lib/seahorse/model/operation.rb +3 -0
- data/lib/seahorse/model/shapes.rb +2 -2
- data/sig/aws-sdk-core/async_client_stubs.rbs +21 -0
- data/sig/aws-sdk-core/client_stubs.rbs +10 -0
- data/sig/aws-sdk-core/errors.rbs +22 -0
- data/sig/aws-sdk-core/resources/collection.rbs +21 -0
- data/sig/aws-sdk-core/structure.rbs +4 -0
- data/sig/aws-sdk-core/telemetry/base.rbs +46 -0
- data/sig/aws-sdk-core/telemetry/otel.rbs +22 -0
- data/sig/aws-sdk-core/telemetry/span_kind.rbs +15 -0
- data/sig/aws-sdk-core/telemetry/span_status.rbs +24 -0
- data/sig/aws-sdk-core/waiters/errors.rbs +20 -0
- data/sig/aws-sdk-core.rbs +7 -0
- data/sig/seahorse/client/async_base.rbs +18 -0
- data/sig/seahorse/client/base.rbs +25 -0
- data/sig/seahorse/client/handler_builder.rbs +16 -0
- data/sig/seahorse/client/response.rbs +61 -0
- metadata +92 -23
- /data/lib/aws-sdk-core/xml/parser/{engines/libxml.rb → libxml_engine.rb} +0 -0
- /data/lib/aws-sdk-core/xml/parser/{engines/nokogiri.rb → nokogiri_engine.rb} +0 -0
- /data/lib/aws-sdk-core/xml/parser/{engines/ox.rb → ox_engine.rb} +0 -0
- /data/lib/aws-sdk-core/xml/parser/{engines/rexml.rb → rexml_engine.rb} +0 -0
|
@@ -12,24 +12,43 @@ module Seahorse
|
|
|
12
12
|
@sync_queue = options[:sync_queue]
|
|
13
13
|
end
|
|
14
14
|
|
|
15
|
+
# @return [RequestContext]
|
|
15
16
|
def context
|
|
16
17
|
@response.context
|
|
17
18
|
end
|
|
18
19
|
|
|
20
|
+
# @return [StandardError, nil]
|
|
19
21
|
def error
|
|
20
22
|
@response.error
|
|
21
23
|
end
|
|
22
24
|
|
|
25
|
+
# @overload on(status_code, &block)
|
|
26
|
+
# @param [Integer] status_code The block will be
|
|
27
|
+
# triggered only for responses with the given status code.
|
|
28
|
+
#
|
|
29
|
+
# @overload on(status_code_range, &block)
|
|
30
|
+
# @param [Range<Integer>] status_code_range The block will be
|
|
31
|
+
# triggered only for responses with a status code that falls
|
|
32
|
+
# witin the given range.
|
|
33
|
+
#
|
|
34
|
+
# @return [self]
|
|
23
35
|
def on(range, &block)
|
|
24
36
|
@response.on(range, &block)
|
|
25
37
|
self
|
|
26
38
|
end
|
|
27
39
|
|
|
40
|
+
# @api private
|
|
28
41
|
def on_complete(&block)
|
|
29
42
|
@response.on_complete(&block)
|
|
30
43
|
self
|
|
31
44
|
end
|
|
32
45
|
|
|
46
|
+
# @return [Boolean] Returns `true` if the response is complete with
|
|
47
|
+
# no error.
|
|
48
|
+
def successful?
|
|
49
|
+
@response.error.nil?
|
|
50
|
+
end
|
|
51
|
+
|
|
33
52
|
def wait
|
|
34
53
|
if error && context.config.raise_response_errors
|
|
35
54
|
raise error
|
data/lib/seahorse/client/base.rb
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require 'thread'
|
|
4
|
-
|
|
5
3
|
module Seahorse
|
|
6
4
|
module Client
|
|
7
5
|
class Base
|
|
@@ -9,6 +7,7 @@ module Seahorse
|
|
|
9
7
|
include HandlerBuilder
|
|
10
8
|
|
|
11
9
|
# default plugins
|
|
10
|
+
# @api private
|
|
12
11
|
@plugins = PluginList.new([
|
|
13
12
|
Plugins::Endpoint,
|
|
14
13
|
Plugins::NetHttp,
|
|
@@ -59,6 +58,7 @@ module Seahorse
|
|
|
59
58
|
def build_config(plugins, options)
|
|
60
59
|
config = Configuration.new
|
|
61
60
|
config.add_option(:api)
|
|
61
|
+
config.add_option(:plugins)
|
|
62
62
|
plugins.each do |plugin|
|
|
63
63
|
plugin.add_options(config) if plugin.respond_to?(:add_options)
|
|
64
64
|
end
|
|
@@ -95,9 +95,9 @@ module Seahorse
|
|
|
95
95
|
class << self
|
|
96
96
|
|
|
97
97
|
def new(options = {})
|
|
98
|
-
plugins = build_plugins
|
|
99
98
|
options = options.dup
|
|
100
|
-
|
|
99
|
+
plugins = build_plugins(self.plugins + options.fetch(:plugins, []))
|
|
100
|
+
plugins = before_initialize(plugins, options)
|
|
101
101
|
client = allocate
|
|
102
102
|
client.send(:initialize, plugins, options)
|
|
103
103
|
client
|
|
@@ -176,8 +176,6 @@ module Seahorse
|
|
|
176
176
|
# @return [Model::Api]
|
|
177
177
|
def set_api(api)
|
|
178
178
|
@api = api
|
|
179
|
-
define_operation_methods
|
|
180
|
-
@api
|
|
181
179
|
end
|
|
182
180
|
|
|
183
181
|
# @option options [Model::Api, Hash] :api ({})
|
|
@@ -196,29 +194,28 @@ module Seahorse
|
|
|
196
194
|
|
|
197
195
|
private
|
|
198
196
|
|
|
199
|
-
def
|
|
200
|
-
operations_module = Module.new
|
|
201
|
-
@api.operation_names.each do |method_name|
|
|
202
|
-
operations_module.send(:define_method, method_name) do |*args, &block|
|
|
203
|
-
params = args[0] || {}
|
|
204
|
-
options = args[1] || {}
|
|
205
|
-
build_request(method_name, params).send_request(options, &block)
|
|
206
|
-
end
|
|
207
|
-
end
|
|
208
|
-
include(operations_module)
|
|
209
|
-
end
|
|
210
|
-
|
|
211
|
-
def build_plugins
|
|
197
|
+
def build_plugins(plugins)
|
|
212
198
|
plugins.map { |plugin| plugin.is_a?(Class) ? plugin.new : plugin }
|
|
213
199
|
end
|
|
214
200
|
|
|
215
201
|
def before_initialize(plugins, options)
|
|
216
|
-
|
|
217
|
-
|
|
202
|
+
queue = Queue.new
|
|
203
|
+
plugins.each { |plugin| queue.push(plugin) }
|
|
204
|
+
until queue.empty?
|
|
205
|
+
plugin = queue.pop
|
|
206
|
+
next unless plugin.respond_to?(:before_initialize)
|
|
207
|
+
|
|
208
|
+
plugins_before = options.fetch(:plugins, [])
|
|
209
|
+
plugin.before_initialize(self, options)
|
|
210
|
+
plugins_after = build_plugins(options.fetch(:plugins, []) - plugins_before)
|
|
211
|
+
# Plugins with before_initialize can add other plugins
|
|
212
|
+
plugins_after.each { |p| queue.push(p); plugins << p }
|
|
218
213
|
end
|
|
214
|
+
plugins
|
|
219
215
|
end
|
|
220
216
|
|
|
221
217
|
def inherited(subclass)
|
|
218
|
+
super
|
|
222
219
|
subclass.instance_variable_set('@plugins', PluginList.new(@plugins))
|
|
223
220
|
end
|
|
224
221
|
|
|
@@ -204,10 +204,6 @@ module Seahorse
|
|
|
204
204
|
def value_at(opt_name)
|
|
205
205
|
value = @struct[opt_name]
|
|
206
206
|
if value.is_a?(Defaults)
|
|
207
|
-
# Legacy endpoints must continue to exist.
|
|
208
|
-
if opt_name == :endpoint && @struct.members.include?(:regional_endpoint)
|
|
209
|
-
@struct[:regional_endpoint] = true
|
|
210
|
-
end
|
|
211
207
|
resolve_defaults(opt_name, value)
|
|
212
208
|
else
|
|
213
209
|
value
|
|
@@ -10,13 +10,8 @@ module Seahorse
|
|
|
10
10
|
module Client
|
|
11
11
|
# @api private
|
|
12
12
|
module H2
|
|
13
|
-
|
|
14
13
|
# H2 Connection build on top of `http/2` gem
|
|
15
|
-
# (requires Ruby >= 2.1)
|
|
16
|
-
# with TLS layer plus ALPN, requires:
|
|
17
|
-
# Ruby >= 2.3 and OpenSSL >= 1.0.2
|
|
18
14
|
class Connection
|
|
19
|
-
|
|
20
15
|
OPTIONS = {
|
|
21
16
|
max_concurrent_streams: 100,
|
|
22
17
|
connection_timeout: 60,
|
|
@@ -27,7 +22,7 @@ module Seahorse
|
|
|
27
22
|
ssl_ca_bundle: nil,
|
|
28
23
|
ssl_ca_directory: nil,
|
|
29
24
|
ssl_ca_store: nil,
|
|
30
|
-
enable_alpn:
|
|
25
|
+
enable_alpn: true
|
|
31
26
|
}
|
|
32
27
|
|
|
33
28
|
# chunk read size at socket
|
|
@@ -41,23 +36,23 @@ module Seahorse
|
|
|
41
36
|
instance_variable_set("@#{opt_name}", value)
|
|
42
37
|
end
|
|
43
38
|
@h2_client = HTTP2::Client.new(
|
|
44
|
-
settings_max_concurrent_streams: max_concurrent_streams
|
|
39
|
+
settings_max_concurrent_streams: @max_concurrent_streams
|
|
45
40
|
)
|
|
46
|
-
@logger
|
|
41
|
+
@logger ||= Logger.new($stdout) if @http_wire_trace
|
|
47
42
|
@chunk_size = options[:read_chunk_size] || CHUNKSIZE
|
|
43
|
+
|
|
48
44
|
@errors = []
|
|
49
45
|
@status = :ready
|
|
46
|
+
|
|
50
47
|
@mutex = Mutex.new # connection can be shared across requests
|
|
51
48
|
@socket = nil
|
|
52
49
|
@socket_thread = nil
|
|
53
50
|
end
|
|
54
51
|
|
|
55
52
|
OPTIONS.keys.each do |attr_name|
|
|
56
|
-
attr_reader
|
|
53
|
+
attr_reader attr_name
|
|
57
54
|
end
|
|
58
55
|
|
|
59
|
-
alias ssl_verify_peer? ssl_verify_peer
|
|
60
|
-
|
|
61
56
|
attr_reader :errors
|
|
62
57
|
|
|
63
58
|
attr_accessor :input_signal_thread
|
|
@@ -110,7 +105,7 @@ module Seahorse
|
|
|
110
105
|
@h2_client << data
|
|
111
106
|
rescue IO::WaitReadable
|
|
112
107
|
begin
|
|
113
|
-
unless IO.select([@socket], nil, nil, connection_read_timeout)
|
|
108
|
+
unless IO.select([@socket], nil, nil, @connection_read_timeout)
|
|
114
109
|
self.debug_output('socket connection read time out')
|
|
115
110
|
self.close!
|
|
116
111
|
else
|
|
@@ -152,11 +147,11 @@ module Seahorse
|
|
|
152
147
|
end
|
|
153
148
|
|
|
154
149
|
def debug_output(msg, type = nil)
|
|
155
|
-
prefix =
|
|
150
|
+
prefix =
|
|
151
|
+
case type
|
|
156
152
|
when :send then '-> '
|
|
157
153
|
when :receive then '<- '
|
|
158
|
-
else
|
|
159
|
-
''
|
|
154
|
+
else ''
|
|
160
155
|
end
|
|
161
156
|
return unless @logger
|
|
162
157
|
_debug_entry(prefix + msg)
|
|
@@ -180,11 +175,13 @@ module Seahorse
|
|
|
180
175
|
@socket.flush
|
|
181
176
|
end
|
|
182
177
|
end
|
|
183
|
-
@
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
178
|
+
if @http_wire_trace
|
|
179
|
+
@h2_client.on(:frame_sent) do |frame|
|
|
180
|
+
debug_output("frame: #{frame.inspect}", :send)
|
|
181
|
+
end
|
|
182
|
+
@h2_client.on(:frame_received) do |frame|
|
|
183
|
+
debug_output("frame: #{frame.inspect}", :receive)
|
|
184
|
+
end
|
|
188
185
|
end
|
|
189
186
|
end
|
|
190
187
|
|
|
@@ -202,7 +199,7 @@ module Seahorse
|
|
|
202
199
|
begin
|
|
203
200
|
tcp.connect_nonblock(addr)
|
|
204
201
|
rescue IO::WaitWritable
|
|
205
|
-
unless IO.select(nil, [tcp], nil, connection_timeout)
|
|
202
|
+
unless IO.select(nil, [tcp], nil, @connection_timeout)
|
|
206
203
|
tcp.close
|
|
207
204
|
raise
|
|
208
205
|
end
|
|
@@ -216,15 +213,15 @@ module Seahorse
|
|
|
216
213
|
|
|
217
214
|
def _tls_context
|
|
218
215
|
ssl_ctx = OpenSSL::SSL::SSLContext.new(:TLSv1_2)
|
|
219
|
-
if ssl_verify_peer
|
|
216
|
+
if @ssl_verify_peer
|
|
220
217
|
ssl_ctx.verify_mode = OpenSSL::SSL::VERIFY_PEER
|
|
221
|
-
ssl_ctx.ca_file = ssl_ca_bundle
|
|
222
|
-
ssl_ctx.ca_path = ssl_ca_directory
|
|
223
|
-
ssl_ctx.cert_store = ssl_ca_store if ssl_ca_store
|
|
218
|
+
ssl_ctx.ca_file = @ssl_ca_bundle || _default_ca_bundle
|
|
219
|
+
ssl_ctx.ca_path = @ssl_ca_directory || _default_ca_directory
|
|
220
|
+
ssl_ctx.cert_store = @ssl_ca_store if @ssl_ca_store
|
|
224
221
|
else
|
|
225
222
|
ssl_ctx.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
|
226
223
|
end
|
|
227
|
-
if enable_alpn
|
|
224
|
+
if @enable_alpn
|
|
228
225
|
debug_output('enabling ALPN for TLS ...')
|
|
229
226
|
ssl_ctx.alpn_protocols = ['h2']
|
|
230
227
|
end
|
|
@@ -232,15 +229,12 @@ module Seahorse
|
|
|
232
229
|
end
|
|
233
230
|
|
|
234
231
|
def _default_ca_bundle
|
|
235
|
-
File.exist?(OpenSSL::X509::DEFAULT_CERT_FILE)
|
|
236
|
-
OpenSSL::X509::DEFAULT_CERT_FILE : nil
|
|
232
|
+
OpenSSL::X509::DEFAULT_CERT_FILE if File.exist?(OpenSSL::X509::DEFAULT_CERT_FILE)
|
|
237
233
|
end
|
|
238
234
|
|
|
239
235
|
def _default_ca_directory
|
|
240
|
-
Dir.exist?(OpenSSL::X509::DEFAULT_CERT_DIR)
|
|
241
|
-
OpenSSL::X509::DEFAULT_CERT_DIR : nil
|
|
236
|
+
OpenSSL::X509::DEFAULT_CERT_DIR if Dir.exist?(OpenSSL::X509::DEFAULT_CERT_DIR)
|
|
242
237
|
end
|
|
243
|
-
|
|
244
238
|
end
|
|
245
239
|
end
|
|
246
240
|
end
|
|
@@ -27,6 +27,12 @@ module Seahorse
|
|
|
27
27
|
class Handler < Client::Handler
|
|
28
28
|
|
|
29
29
|
def call(context)
|
|
30
|
+
span_wrapper(context) { _call(context) }
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
private
|
|
34
|
+
|
|
35
|
+
def _call(context)
|
|
30
36
|
stream = nil
|
|
31
37
|
begin
|
|
32
38
|
conn = context.client.connection
|
|
@@ -80,8 +86,6 @@ module Seahorse
|
|
|
80
86
|
)
|
|
81
87
|
end
|
|
82
88
|
|
|
83
|
-
private
|
|
84
|
-
|
|
85
89
|
def _register_callbacks(resp, stream, stream_mutex, close_condition, sync_queue)
|
|
86
90
|
stream.on(:headers) do |headers|
|
|
87
91
|
resp.signal_headers(headers)
|
|
@@ -126,6 +130,7 @@ module Seahorse
|
|
|
126
130
|
# https://http2.github.io/http2-spec/#rfc.section.8.1.2.3
|
|
127
131
|
def _h2_headers(req)
|
|
128
132
|
headers = {}
|
|
133
|
+
headers[':authority'] = req.endpoint.host
|
|
129
134
|
headers[':method'] = req.http_method.upcase
|
|
130
135
|
headers[':scheme'] = req.endpoint.scheme
|
|
131
136
|
headers[':path'] = req.endpoint.path.empty? ? '/' : req.endpoint.path
|
|
@@ -145,8 +150,14 @@ module Seahorse
|
|
|
145
150
|
end
|
|
146
151
|
end
|
|
147
152
|
|
|
153
|
+
def span_wrapper(context, &block)
|
|
154
|
+
context.tracer.in_span(
|
|
155
|
+
'Handler.H2',
|
|
156
|
+
attributes: Aws::Telemetry.http_request_attrs(context),
|
|
157
|
+
&block
|
|
158
|
+
)
|
|
159
|
+
end
|
|
148
160
|
end
|
|
149
|
-
|
|
150
161
|
end
|
|
151
162
|
end
|
|
152
163
|
end
|
|
@@ -34,7 +34,9 @@ module Seahorse
|
|
|
34
34
|
ssl_ca_bundle: nil,
|
|
35
35
|
ssl_ca_directory: nil,
|
|
36
36
|
ssl_ca_store: nil,
|
|
37
|
-
ssl_timeout: nil
|
|
37
|
+
ssl_timeout: nil,
|
|
38
|
+
ssl_cert: nil,
|
|
39
|
+
ssl_key: nil
|
|
38
40
|
}
|
|
39
41
|
|
|
40
42
|
# @api private
|
|
@@ -119,11 +121,7 @@ module Seahorse
|
|
|
119
121
|
# pool, not counting those currently in use.
|
|
120
122
|
def size
|
|
121
123
|
@pool_mutex.synchronize do
|
|
122
|
-
size
|
|
123
|
-
@pool.each_pair do |endpoint,sessions|
|
|
124
|
-
size += sessions.size
|
|
125
|
-
end
|
|
126
|
-
size
|
|
124
|
+
@pool.values.flatten.size
|
|
127
125
|
end
|
|
128
126
|
end
|
|
129
127
|
|
|
@@ -142,9 +140,7 @@ module Seahorse
|
|
|
142
140
|
# @return [nil]
|
|
143
141
|
def empty!
|
|
144
142
|
@pool_mutex.synchronize do
|
|
145
|
-
@pool.
|
|
146
|
-
sessions.each(&:finish)
|
|
147
|
-
end
|
|
143
|
+
@pool.values.flatten.map(&:finish)
|
|
148
144
|
@pool.clear
|
|
149
145
|
end
|
|
150
146
|
nil
|
|
@@ -252,7 +248,9 @@ module Seahorse
|
|
|
252
248
|
:ssl_ca_bundle => options[:ssl_ca_bundle],
|
|
253
249
|
:ssl_ca_directory => options[:ssl_ca_directory],
|
|
254
250
|
:ssl_ca_store => options[:ssl_ca_store],
|
|
255
|
-
:ssl_timeout => options[:ssl_timeout]
|
|
251
|
+
:ssl_timeout => options[:ssl_timeout],
|
|
252
|
+
:ssl_cert => options[:ssl_cert],
|
|
253
|
+
:ssl_key => options[:ssl_key]
|
|
256
254
|
}
|
|
257
255
|
end
|
|
258
256
|
|
|
@@ -297,6 +295,8 @@ module Seahorse
|
|
|
297
295
|
http.ca_file = ssl_ca_bundle if ssl_ca_bundle
|
|
298
296
|
http.ca_path = ssl_ca_directory if ssl_ca_directory
|
|
299
297
|
http.cert_store = ssl_ca_store if ssl_ca_store
|
|
298
|
+
http.cert = ssl_cert if ssl_cert
|
|
299
|
+
http.key = ssl_key if ssl_key
|
|
300
300
|
else
|
|
301
301
|
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
|
302
302
|
end
|
|
@@ -312,7 +312,7 @@ module Seahorse
|
|
|
312
312
|
# @note **Must** be called behind a `@pool_mutex` synchronize block.
|
|
313
313
|
def _clean
|
|
314
314
|
now = Aws::Util.monotonic_milliseconds
|
|
315
|
-
@pool.
|
|
315
|
+
@pool.values.each do |sessions|
|
|
316
316
|
sessions.delete_if do |session|
|
|
317
317
|
if session.last_used.nil? or now - session.last_used > http_idle_timeout * 1000
|
|
318
318
|
session.finish
|
|
@@ -336,6 +336,8 @@ module Seahorse
|
|
|
336
336
|
attr_reader :last_used
|
|
337
337
|
|
|
338
338
|
def __getobj__
|
|
339
|
+
return yield if block_given? && !defined?(@http)
|
|
340
|
+
|
|
339
341
|
@http
|
|
340
342
|
end
|
|
341
343
|
|
|
@@ -23,17 +23,12 @@ module Seahorse
|
|
|
23
23
|
|
|
24
24
|
NETWORK_ERRORS = [
|
|
25
25
|
SocketError, EOFError, IOError, Timeout::Error,
|
|
26
|
-
Errno::ECONNABORTED, Errno::ECONNRESET, Errno::EPIPE,
|
|
27
|
-
Errno::
|
|
28
|
-
|
|
26
|
+
Errno::ECONNABORTED, Errno::ECONNRESET, Errno::EPIPE, Errno::EINVAL,
|
|
27
|
+
Errno::ETIMEDOUT, Errno::EHOSTUNREACH, Errno::ECONNREFUSED,
|
|
28
|
+
OpenSSL::SSL::SSLError, OpenSSL::SSL::SSLErrorWaitReadable,
|
|
29
29
|
Net::HTTPFatalError # for proxy connection failures
|
|
30
30
|
]
|
|
31
31
|
|
|
32
|
-
# does not exist in Ruby 1.9.3
|
|
33
|
-
if OpenSSL::SSL.const_defined?(:SSLErrorWaitReadable)
|
|
34
|
-
NETWORK_ERRORS << OpenSSL::SSL::SSLErrorWaitReadable
|
|
35
|
-
end
|
|
36
|
-
|
|
37
32
|
# @api private
|
|
38
33
|
DNS_ERROR_MESSAGES = [
|
|
39
34
|
'getaddrinfo: nodename nor servname provided, or not known', # MacOS
|
|
@@ -47,7 +42,13 @@ module Seahorse
|
|
|
47
42
|
# @param [RequestContext] context
|
|
48
43
|
# @return [Response]
|
|
49
44
|
def call(context)
|
|
50
|
-
|
|
45
|
+
span_wrapper(context) do
|
|
46
|
+
transmit(
|
|
47
|
+
context.config,
|
|
48
|
+
context.http_request,
|
|
49
|
+
context.http_response
|
|
50
|
+
)
|
|
51
|
+
end
|
|
51
52
|
Response.new(context: context)
|
|
52
53
|
end
|
|
53
54
|
|
|
@@ -197,6 +198,17 @@ module Seahorse
|
|
|
197
198
|
end
|
|
198
199
|
end
|
|
199
200
|
|
|
201
|
+
def span_wrapper(context, &block)
|
|
202
|
+
context.tracer.in_span(
|
|
203
|
+
'Handler.NetHttp',
|
|
204
|
+
attributes: Aws::Telemetry.http_request_attrs(context)
|
|
205
|
+
) do |span|
|
|
206
|
+
block.call
|
|
207
|
+
span.add_attributes(
|
|
208
|
+
Aws::Telemetry.http_response_attrs(context)
|
|
209
|
+
)
|
|
210
|
+
end
|
|
211
|
+
end
|
|
200
212
|
end
|
|
201
213
|
end
|
|
202
214
|
end
|
|
@@ -12,12 +12,9 @@ module Seahorse
|
|
|
12
12
|
|
|
13
13
|
def self.apply!
|
|
14
14
|
Net::HTTPGenericRequest.prepend(PatchDefaultContentType)
|
|
15
|
-
return unless RUBY_VERSION < '2.5'
|
|
16
|
-
|
|
17
|
-
Net::HTTP::IDEMPOTENT_METHODS_.clear
|
|
18
15
|
end
|
|
19
16
|
|
|
20
|
-
# For requests with
|
|
17
|
+
# For requests with bodies, Net::HTTP sets a default content type of:
|
|
21
18
|
# 'application/x-www-form-urlencoded'
|
|
22
19
|
# There are cases where we should not send content type at all.
|
|
23
20
|
# Even when no body is supplied, Net::HTTP uses a default empty body
|
|
@@ -111,7 +111,15 @@ module Seahorse
|
|
|
111
111
|
|
|
112
112
|
def initialize(name, options = {})
|
|
113
113
|
@name = name
|
|
114
|
+
# prevent unstable object shapes by ensuring
|
|
115
|
+
# order and presence of instance variables
|
|
116
|
+
@default = nil
|
|
117
|
+
@default_block = nil
|
|
118
|
+
@required = nil
|
|
119
|
+
@doc_type = nil
|
|
114
120
|
@doc_default = nil
|
|
121
|
+
@docstring = nil
|
|
122
|
+
@rbs_type = nil
|
|
115
123
|
options.each_pair do |opt_name, opt_value|
|
|
116
124
|
self.send("#{opt_name}=", opt_value)
|
|
117
125
|
end
|
|
@@ -124,6 +132,7 @@ module Seahorse
|
|
|
124
132
|
attr_accessor :doc_type
|
|
125
133
|
attr_writer :doc_default
|
|
126
134
|
attr_accessor :docstring
|
|
135
|
+
attr_accessor :rbs_type
|
|
127
136
|
|
|
128
137
|
def doc_default(options)
|
|
129
138
|
if @doc_default.nil? && !default.is_a?(Proc)
|
|
@@ -53,10 +53,10 @@ When `true`, SSL peer certificates are verified when establishing a connection.
|
|
|
53
53
|
When `true`, HTTP2 debug output will be sent to the `:logger`.
|
|
54
54
|
DOCS
|
|
55
55
|
|
|
56
|
-
option(:enable_alpn, default:
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
56
|
+
option(:enable_alpn, default: true, doc_type: 'Boolean', docstring: <<-DOCS)
|
|
57
|
+
Set to `false` to disable ALPN in HTTP2 over TLS. ALPN requires Openssl version >= 1.0.2.
|
|
58
|
+
Note: RFC7540 requires HTTP2 to use ALPN over TLS but some
|
|
59
|
+
services may not fully support ALPN and require setting this to `false`.
|
|
60
60
|
DOCS
|
|
61
61
|
|
|
62
62
|
option(:logger)
|
|
@@ -7,37 +7,78 @@ module Seahorse
|
|
|
7
7
|
module Plugins
|
|
8
8
|
class NetHttp < Plugin
|
|
9
9
|
|
|
10
|
-
option(:http_proxy, default: nil, doc_type: String, docstring:
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
option(:http_proxy, default: nil, doc_type: "URI::HTTP,String", docstring: <<-DOCS)
|
|
11
|
+
A proxy to send requests through. Formatted like 'http://proxy.com:123'.
|
|
12
|
+
DOCS
|
|
13
|
+
|
|
14
|
+
option(:http_open_timeout, default: 15, doc_type: Float, docstring: <<-DOCS) do |cfg|
|
|
15
|
+
The default number of seconds to wait for response data.
|
|
16
|
+
This value can safely be set per-request on the session.
|
|
17
|
+
DOCS
|
|
13
18
|
resolve_http_open_timeout(cfg)
|
|
14
19
|
end
|
|
15
20
|
|
|
16
|
-
option(:http_read_timeout, default: 60, doc_type:
|
|
21
|
+
option(:http_read_timeout, default: 60, doc_type: Float, docstring: <<-DOCS) do |cfg|
|
|
22
|
+
The default number of seconds to wait for response data.
|
|
23
|
+
This value can safely be set per-request on the session.
|
|
24
|
+
DOCS
|
|
17
25
|
resolve_http_read_timeout(cfg)
|
|
18
26
|
end
|
|
19
27
|
|
|
20
|
-
option(:http_idle_timeout, default: 5, doc_type:
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
option(:
|
|
27
|
-
|
|
28
|
-
|
|
28
|
+
option(:http_idle_timeout, default: 5, doc_type: Float, docstring: <<-DOCS)
|
|
29
|
+
The number of seconds a connection is allowed to sit idle before it
|
|
30
|
+
is considered stale. Stale connections are closed and removed from the
|
|
31
|
+
pool before making a request.
|
|
32
|
+
DOCS
|
|
33
|
+
|
|
34
|
+
option(:http_continue_timeout, default: 1, doc_type: Float, docstring: <<-DOCS)
|
|
35
|
+
The number of seconds to wait for a 100-continue response before sending the
|
|
36
|
+
request body. This option has no effect unless the request has "Expect"
|
|
37
|
+
header set to "100-continue". Defaults to `nil` which disables this
|
|
38
|
+
behaviour. This value can safely be set per request on the session.
|
|
39
|
+
DOCS
|
|
40
|
+
|
|
41
|
+
option(:http_wire_trace, default: false, doc_type: 'Boolean', docstring: <<-DOCS)
|
|
42
|
+
When `true`, HTTP debug output will be sent to the `:logger`.
|
|
43
|
+
DOCS
|
|
44
|
+
|
|
45
|
+
option(:ssl_verify_peer, default: true, doc_type: 'Boolean', docstring: <<-DOCS)
|
|
46
|
+
When `true`, SSL peer certificates are verified when establishing a connection.
|
|
47
|
+
DOCS
|
|
48
|
+
|
|
49
|
+
option(:ssl_ca_bundle, doc_type: String, docstring: <<-DOCS) do |cfg|
|
|
50
|
+
Full path to the SSL certificate authority bundle file that should be used when
|
|
51
|
+
verifying peer certificates. If you do not pass `:ssl_ca_bundle` or
|
|
52
|
+
`:ssl_ca_directory` the the system default will be used if available.
|
|
53
|
+
DOCS
|
|
29
54
|
ENV['AWS_CA_BUNDLE'] ||
|
|
30
55
|
Aws.shared_config.ca_bundle(profile: cfg.profile) if cfg.respond_to?(:profile)
|
|
31
56
|
end
|
|
32
57
|
|
|
33
|
-
option(:ssl_ca_directory, default: nil, doc_type: String, docstring:
|
|
58
|
+
option(:ssl_ca_directory, default: nil, doc_type: String, docstring: <<-DOCS)
|
|
59
|
+
Full path of the directory that contains the unbundled SSL certificate
|
|
60
|
+
authority files for verifying peer certificates. If you do
|
|
61
|
+
not pass `:ssl_ca_bundle` or `:ssl_ca_directory` the the system
|
|
62
|
+
default will be used if available.
|
|
63
|
+
DOCS
|
|
34
64
|
|
|
35
|
-
option(:ssl_ca_store, default: nil, doc_type: String, docstring:
|
|
65
|
+
option(:ssl_ca_store, default: nil, doc_type: String, docstring: <<-DOCS)
|
|
66
|
+
Sets the X509::Store to verify peer certificate.
|
|
67
|
+
DOCS
|
|
36
68
|
|
|
37
|
-
option(:ssl_timeout, default: nil, doc_type: Float, docstring: '') do |cfg|
|
|
69
|
+
option(:ssl_timeout, default: nil, doc_type: Float, docstring: 'Sets the SSL timeout in seconds') do |cfg|
|
|
38
70
|
resolve_ssl_timeout(cfg)
|
|
39
71
|
end
|
|
40
72
|
|
|
73
|
+
option(:ssl_cert, default: nil, doc_type: OpenSSL::X509::Certificate, docstring: <<-DOCS)
|
|
74
|
+
Sets a client certificate when creating http connections.
|
|
75
|
+
DOCS
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
option(:ssl_key, default: nil, doc_type: OpenSSL::PKey, docstring: <<-DOCS)
|
|
79
|
+
Sets a client key when creating http connections.
|
|
80
|
+
DOCS
|
|
81
|
+
|
|
41
82
|
option(:logger) # for backwards compat
|
|
42
83
|
|
|
43
84
|
handler(Client::NetHttp::Handler, step: :send)
|