aws-sdk-core 3.171.0 → 3.181.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +106 -0
- data/VERSION +1 -1
- data/lib/aws-defaults/default_configuration.rb +4 -4
- data/lib/aws-sdk-core/credential_provider.rb +3 -0
- data/lib/aws-sdk-core/endpoints.rb +5 -1
- data/lib/aws-sdk-core/ini_parser.rb +7 -0
- data/lib/aws-sdk-core/json/error_handler.rb +15 -5
- data/lib/aws-sdk-core/log/formatter.rb +6 -0
- data/lib/aws-sdk-core/pageable_response.rb +3 -1
- data/lib/aws-sdk-core/plugins/checksum_algorithm.rb +1 -1
- data/lib/aws-sdk-core/plugins/regional_endpoint.rb +109 -33
- data/lib/aws-sdk-core/plugins/request_compression.rb +217 -0
- data/lib/aws-sdk-core/plugins/sign.rb +1 -0
- data/lib/aws-sdk-core/plugins/user_agent.rb +117 -14
- data/lib/aws-sdk-core/refreshing_credentials.rb +0 -6
- data/lib/aws-sdk-core/shared_config.rb +46 -18
- data/lib/aws-sdk-core/sso_credentials.rb +1 -1
- data/lib/aws-sdk-core/stubbing/stub_data.rb +11 -0
- data/lib/aws-sdk-core/waiters/poller.rb +3 -1
- data/lib/aws-sdk-sso/client.rb +21 -1
- data/lib/aws-sdk-sso/endpoints.rb +1 -0
- data/lib/aws-sdk-sso.rb +1 -1
- data/lib/aws-sdk-ssooidc/client.rb +21 -1
- data/lib/aws-sdk-ssooidc/endpoints.rb +1 -0
- data/lib/aws-sdk-ssooidc.rb +1 -1
- data/lib/aws-sdk-sts/client.rb +137 -111
- data/lib/aws-sdk-sts/client_api.rb +10 -0
- data/lib/aws-sdk-sts/endpoint_provider.rb +81 -78
- data/lib/aws-sdk-sts/endpoints.rb +1 -0
- data/lib/aws-sdk-sts/types.rb +35 -11
- data/lib/aws-sdk-sts.rb +1 -1
- data/lib/seahorse/client/configuration.rb +0 -4
- data/lib/seahorse/client/plugins/request_callback.rb +31 -0
- data/lib/seahorse/client/response.rb +6 -0
- data/lib/seahorse/model/operation.rb +3 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 146ac9f16fcd2580c959c58a93c911c2fb023caea3d9113fa29da22e85627eaf
|
4
|
+
data.tar.gz: f33db208ab8d3cac7a8f96d4c7e8c8609ca48b4a01c5db136c5210cbe70f8ca2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5074b88e182acdfb8ef77a11e72bd3a23b737f124103e213d95fd2e09d59e93364da10ca99f7b2c7d8ec4754bcff474480c8ba301f313bebf66e08e4f91bb5b9
|
7
|
+
data.tar.gz: 7d6e5a2a1442fd5c926b6f691d505eaf830e47ef9eac5a6f9f984f8d9bedeb161bf5dfada064b67baab61c9c8c4772bcfbacaaa1d75ddafd283ba6b87e5db8a9
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,112 @@
|
|
1
1
|
Unreleased Changes
|
2
2
|
------------------
|
3
3
|
|
4
|
+
3.181.0 (2023-08-22)
|
5
|
+
------------------
|
6
|
+
|
7
|
+
* Feature - Add support for `on_chunk_received` callback.
|
8
|
+
|
9
|
+
3.180.3 (2023-08-09)
|
10
|
+
------------------
|
11
|
+
|
12
|
+
* Issue - Add support for sso-session names with whitespace configured by the CLI `aws sso configure` command (#2895).
|
13
|
+
|
14
|
+
3.180.2 (2023-08-07)
|
15
|
+
------------------
|
16
|
+
|
17
|
+
* Issue - Fix parsing of ini files with mixes of blank properties and nested configurations.
|
18
|
+
|
19
|
+
3.180.1 (2023-07-31)
|
20
|
+
------------------
|
21
|
+
|
22
|
+
* Issue - Remove checksums from default stubs (#2888).
|
23
|
+
|
24
|
+
3.180.0 (2023-07-25)
|
25
|
+
------------------
|
26
|
+
|
27
|
+
* Feature - Updated Aws::STS::Client with the latest API changes.
|
28
|
+
|
29
|
+
3.179.0 (2023-07-24)
|
30
|
+
------------------
|
31
|
+
|
32
|
+
* Feature - Add `checksum_validated` method to response.
|
33
|
+
|
34
|
+
3.178.0 (2023-07-11)
|
35
|
+
------------------
|
36
|
+
|
37
|
+
* Feature - Updated Aws::STS::Client with the latest API changes.
|
38
|
+
|
39
|
+
* Feature - Updated Aws::SSOOIDC::Client with the latest API changes.
|
40
|
+
|
41
|
+
* Feature - Updated Aws::SSO::Client with the latest API changes.
|
42
|
+
|
43
|
+
* Feature - Add support for configuring the endpoint URL in the shared configuration file or via an environment variable for a specific AWS service or all AWS services.
|
44
|
+
|
45
|
+
3.177.0 (2023-07-06)
|
46
|
+
------------------
|
47
|
+
|
48
|
+
* Feature - Updated Aws::STS::Client with the latest API changes.
|
49
|
+
|
50
|
+
* Feature - Updated Aws::SSOOIDC::Client with the latest API changes.
|
51
|
+
|
52
|
+
* Feature - Updated Aws::SSO::Client with the latest API changes.
|
53
|
+
|
54
|
+
* Feature - Add support for Request Compression.
|
55
|
+
|
56
|
+
3.176.1 (2023-06-29)
|
57
|
+
------------------
|
58
|
+
|
59
|
+
* Issue - Fix signing for S3/S3 Control and `aws-crt` gem for certain object keys (#2849).
|
60
|
+
|
61
|
+
* Issue - Ensure `SSOCredentials` `#expiration` is a `Time` (#2874)
|
62
|
+
|
63
|
+
3.176.0 (2023-06-28)
|
64
|
+
------------------
|
65
|
+
|
66
|
+
* Feature - Add :expiration accessor to `CredentialProvider` and do not refresh credentials when checking expiration (#2872).
|
67
|
+
|
68
|
+
3.175.0 (2023-06-15)
|
69
|
+
------------------
|
70
|
+
|
71
|
+
* Feature - Updated Aws::STS::Client with the latest API changes.
|
72
|
+
|
73
|
+
* Feature - Updated Aws::SSOOIDC::Client with the latest API changes.
|
74
|
+
|
75
|
+
* Feature - Updated Aws::SSO::Client with the latest API changes.
|
76
|
+
|
77
|
+
3.174.0 (2023-05-31)
|
78
|
+
------------------
|
79
|
+
|
80
|
+
* Feature - Updated Aws::STS::Client with the latest API changes.
|
81
|
+
|
82
|
+
* Feature - Updated Aws::SSOOIDC::Client with the latest API changes.
|
83
|
+
|
84
|
+
* Feature - Updated Aws::SSO::Client with the latest API changes.
|
85
|
+
|
86
|
+
* Feature - Improve User-Agent metrics tracking.
|
87
|
+
|
88
|
+
3.173.1 (2023-05-24)
|
89
|
+
------------------
|
90
|
+
|
91
|
+
* Issue - Updated `checksum_algorithm` plugin to use IO.copy_stream for JRuby.
|
92
|
+
|
93
|
+
3.173.0 (2023-05-18)
|
94
|
+
------------------
|
95
|
+
|
96
|
+
* Feature - Updated Aws::STS::Client with the latest API changes.
|
97
|
+
|
98
|
+
3.172.0 (2023-05-08)
|
99
|
+
------------------
|
100
|
+
|
101
|
+
* Feature - Updated Aws::STS::Client with the latest API changes.
|
102
|
+
|
103
|
+
* Feature - Add :region option to `Aws::Log::Formatter`.
|
104
|
+
|
105
|
+
3.171.1 (2023-05-04)
|
106
|
+
------------------
|
107
|
+
|
108
|
+
* Issue - Fix error code parsing in AWS query compatible JSON services.
|
109
|
+
|
4
110
|
3.171.0 (2023-03-22)
|
5
111
|
------------------
|
6
112
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
3.
|
1
|
+
3.181.0
|
@@ -20,7 +20,7 @@ module Aws
|
|
20
20
|
# * Globally via the "AWS_DEFAULTS_MODE" environment variable.
|
21
21
|
#
|
22
22
|
#
|
23
|
-
#
|
23
|
+
# #defaults START - documentation
|
24
24
|
# The following `:default_mode` values are supported:
|
25
25
|
#
|
26
26
|
# * `'standard'` -
|
@@ -105,10 +105,10 @@ module Aws
|
|
105
105
|
# [2]: https://docs.aws.amazon.com/sdkref/latest/guide/setting-global-retry_mode.html
|
106
106
|
# [3]: https://docs.aws.amazon.com/sdkref/latest/guide/setting-global-sts_regional_endpoints.html
|
107
107
|
#
|
108
|
-
#
|
108
|
+
# #defaults END - documentation
|
109
109
|
module DefaultsModeConfiguration
|
110
110
|
# @api private
|
111
|
-
#
|
111
|
+
# #defaults START - configuration
|
112
112
|
SDK_DEFAULT_CONFIGURATION =
|
113
113
|
{
|
114
114
|
"version" => 1,
|
@@ -148,6 +148,6 @@ module Aws
|
|
148
148
|
}
|
149
149
|
}
|
150
150
|
}
|
151
|
-
#
|
151
|
+
# #defaults END - configuration
|
152
152
|
end
|
153
153
|
end
|
@@ -39,7 +39,11 @@ module Aws
|
|
39
39
|
auth_scheme = { 'name' => 'sigv4' }
|
40
40
|
merge_signing_defaults(auth_scheme, context.config)
|
41
41
|
when 's3', 's3v4'
|
42
|
-
auth_scheme = {
|
42
|
+
auth_scheme = {
|
43
|
+
'name' => 'sigv4',
|
44
|
+
'disableDoubleEncoding' => true,
|
45
|
+
'disableNormalizePath' => true
|
46
|
+
}
|
43
47
|
merge_signing_defaults(auth_scheme, context.config)
|
44
48
|
when 'bearer'
|
45
49
|
{ 'name' => 'bearer' }
|
@@ -8,6 +8,8 @@ module Aws
|
|
8
8
|
def ini_parse(raw)
|
9
9
|
current_profile = nil
|
10
10
|
current_prefix = nil
|
11
|
+
item = nil
|
12
|
+
previous_item = nil
|
11
13
|
raw.lines.inject({}) do |acc, line|
|
12
14
|
line = line.split(/^|\s;/).first # remove comments
|
13
15
|
profile = line.match(/^\[([^\[\]]+)\]\s*(#.+)?$/) unless line.nil?
|
@@ -17,11 +19,16 @@ module Aws
|
|
17
19
|
current_profile = named_profile[1] if named_profile
|
18
20
|
elsif current_profile
|
19
21
|
unless line.nil?
|
22
|
+
previous_item = item
|
20
23
|
item = line.match(/^(.+?)\s*=\s*(.+?)\s*$/)
|
21
24
|
prefix = line.match(/^(.+?)\s*=\s*$/)
|
22
25
|
end
|
23
26
|
if item && item[1].match(/^\s+/)
|
24
27
|
# Need to add lines to a nested configuration.
|
28
|
+
if current_prefix.nil? && previous_item[2].strip.empty?
|
29
|
+
current_prefix = previous_item[1]
|
30
|
+
acc[current_profile][current_prefix] = {}
|
31
|
+
end
|
25
32
|
inner_item = line.match(/^\s*(.+?)\s*=\s*(.+?)\s*$/)
|
26
33
|
acc[current_profile] ||= {}
|
27
34
|
acc[current_profile][current_prefix] ||= {}
|
@@ -26,11 +26,13 @@ module Aws
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def error_code(json, context)
|
29
|
-
code =
|
30
|
-
context
|
31
|
-
|
32
|
-
|
33
|
-
|
29
|
+
code =
|
30
|
+
if aws_query_error?(context)
|
31
|
+
error = context.http_response.headers['x-amzn-query-error'].split(';')[0]
|
32
|
+
remove_prefix(error, context)
|
33
|
+
else
|
34
|
+
json['__type']
|
35
|
+
end
|
34
36
|
code ||= json['code']
|
35
37
|
code ||= context.http_response.headers['x-amzn-errortype']
|
36
38
|
if code
|
@@ -45,6 +47,14 @@ module Aws
|
|
45
47
|
context.http_response.headers['x-amzn-query-error']
|
46
48
|
end
|
47
49
|
|
50
|
+
def remove_prefix(error_code, context)
|
51
|
+
if prefix = context.config.api.metadata['errorPrefix']
|
52
|
+
error_code.sub(/^#{prefix}/, '')
|
53
|
+
else
|
54
|
+
error_code
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
48
58
|
def error_message(code, json)
|
49
59
|
if code == 'RequestEntityTooLarge'
|
50
60
|
'Request body must be less than 1 MB'
|
@@ -26,6 +26,8 @@ module Aws
|
|
26
26
|
#
|
27
27
|
# You can put any of these placeholders into you pattern.
|
28
28
|
#
|
29
|
+
# * `:region` - The region configured for the client.
|
30
|
+
#
|
29
31
|
# * `:client_class` - The name of the client class.
|
30
32
|
#
|
31
33
|
# * `:operation` - The name of the client request method.
|
@@ -116,6 +118,10 @@ module Aws
|
|
116
118
|
|
117
119
|
private
|
118
120
|
|
121
|
+
def _region(response)
|
122
|
+
response.context.config.region
|
123
|
+
end
|
124
|
+
|
119
125
|
def _client_class(response)
|
120
126
|
response.context.client.class.name
|
121
127
|
end
|
@@ -201,7 +201,9 @@ module Aws
|
|
201
201
|
def next_response(params)
|
202
202
|
params = next_page_params(params)
|
203
203
|
request = context.client.build_request(context.operation_name, params)
|
204
|
-
|
204
|
+
Aws::Plugins::UserAgent.feature('paginator') do
|
205
|
+
request.send_request
|
206
|
+
end
|
205
207
|
end
|
206
208
|
|
207
209
|
def next_page_params(params)
|
@@ -47,44 +47,21 @@ is set to `true`.
|
|
47
47
|
# Legacy endpoints must continue to be generated at client time.
|
48
48
|
option(:regional_endpoint, false)
|
49
49
|
|
50
|
-
|
51
|
-
|
52
|
-
|
50
|
+
option(:ignore_configured_endpoint_urls,
|
51
|
+
doc_type: 'Boolean',
|
52
|
+
docstring: <<-DOCS) do |cfg|
|
53
|
+
Setting to true disables use of endpoint URLs provided via environment
|
54
|
+
variables and the shared configuration file.
|
55
|
+
DOCS
|
56
|
+
resolve_ignore_configured_endpoint_urls(cfg)
|
57
|
+
end
|
58
|
+
|
53
59
|
option(:endpoint, doc_type: String, docstring: <<-DOCS) do |cfg|
|
54
60
|
The client endpoint is normally constructed from the `:region`
|
55
61
|
option. You should only configure an `:endpoint` when connecting
|
56
62
|
to test or custom endpoints. This should be a valid HTTP(S) URI.
|
57
63
|
DOCS
|
58
|
-
|
59
|
-
if cfg.region && endpoint_prefix
|
60
|
-
if cfg.respond_to?(:sts_regional_endpoints)
|
61
|
-
sts_regional = cfg.sts_regional_endpoints
|
62
|
-
end
|
63
|
-
|
64
|
-
# check region is a valid RFC host label
|
65
|
-
unless Seahorse::Util.host_label?(cfg.region)
|
66
|
-
raise Errors::InvalidRegionError
|
67
|
-
end
|
68
|
-
|
69
|
-
region = cfg.region
|
70
|
-
new_region = region.gsub('fips-', '').gsub('-fips', '')
|
71
|
-
if region != new_region
|
72
|
-
warn("Legacy region #{region} was transformed to #{new_region}."\
|
73
|
-
'`use_fips_endpoint` config was set to true.')
|
74
|
-
cfg.override_config(:use_fips_endpoint, true)
|
75
|
-
cfg.override_config(:region, new_region)
|
76
|
-
end
|
77
|
-
|
78
|
-
Aws::Partitions::EndpointProvider.resolve(
|
79
|
-
cfg.region,
|
80
|
-
endpoint_prefix,
|
81
|
-
sts_regional,
|
82
|
-
{
|
83
|
-
dualstack: cfg.use_dualstack_endpoint,
|
84
|
-
fips: cfg.use_fips_endpoint
|
85
|
-
}
|
86
|
-
)
|
87
|
-
end
|
64
|
+
resolve_endpoint(cfg)
|
88
65
|
end
|
89
66
|
|
90
67
|
def after_initialize(client)
|
@@ -117,6 +94,105 @@ to test or custom endpoints. This should be a valid HTTP(S) URI.
|
|
117
94
|
value ||= Aws.shared_config.use_fips_endpoint(profile: cfg.profile)
|
118
95
|
Aws::Util.str_2_bool(value) || false
|
119
96
|
end
|
97
|
+
|
98
|
+
def resolve_ignore_configured_endpoint_urls(cfg)
|
99
|
+
value = ENV['AWS_IGNORE_CONFIGURED_ENDPOINT_URLS']
|
100
|
+
value ||= Aws.shared_config.ignore_configured_endpoint_urls(profile: cfg.profile)
|
101
|
+
Aws::Util.str_2_bool(value&.downcase) || false
|
102
|
+
end
|
103
|
+
|
104
|
+
# NOTE: with Endpoints 2.0, some of this logic is deprecated
|
105
|
+
# but because new old service gems may depend on new core versions
|
106
|
+
# we must preserve that behavior.
|
107
|
+
# Additional behavior controls the setting of the custom SDK::Endpoint
|
108
|
+
# parameter.
|
109
|
+
# When the `regional_endpoint` config is set to true - this indicates to
|
110
|
+
# Endpoints2.0 that a custom endpoint has NOT been configured by the user.
|
111
|
+
def resolve_endpoint(cfg)
|
112
|
+
endpoint = resolve_custom_config_endpoint(cfg)
|
113
|
+
endpoint_prefix = cfg.api.metadata['endpointPrefix']
|
114
|
+
|
115
|
+
return endpoint unless endpoint.nil? && cfg.region && endpoint_prefix
|
116
|
+
|
117
|
+
validate_region!(cfg.region)
|
118
|
+
handle_legacy_pseudo_regions(cfg)
|
119
|
+
|
120
|
+
# set regional_endpoint flag - this indicates to Endpoints 2.0
|
121
|
+
# that a custom endpoint has NOT been configured by the user
|
122
|
+
cfg.override_config(:regional_endpoint, true)
|
123
|
+
|
124
|
+
resolve_legacy_endpoint(cfg)
|
125
|
+
end
|
126
|
+
|
127
|
+
# get a custom configured endpoint from ENV or configuration
|
128
|
+
def resolve_custom_config_endpoint(cfg)
|
129
|
+
return if cfg.ignore_configured_endpoint_urls
|
130
|
+
|
131
|
+
|
132
|
+
env_service_endpoint(cfg) || env_global_endpoint(cfg) || shared_config_endpoint(cfg)
|
133
|
+
end
|
134
|
+
|
135
|
+
def env_service_endpoint(cfg)
|
136
|
+
service_id = cfg.api.metadata['serviceId'] || cfg.api.metadata['endpointPrefix']
|
137
|
+
env_service_id = service_id.gsub(" ", "_").upcase
|
138
|
+
return unless endpoint = ENV["AWS_ENDPOINT_URL_#{env_service_id}"]
|
139
|
+
|
140
|
+
cfg.logger&.debug(
|
141
|
+
"Endpoint configured from ENV['AWS_ENDPOINT_URL_#{env_service_id}']: #{endpoint}\n")
|
142
|
+
endpoint
|
143
|
+
end
|
144
|
+
|
145
|
+
def env_global_endpoint(cfg)
|
146
|
+
return unless endpoint = ENV['AWS_ENDPOINT_URL']
|
147
|
+
|
148
|
+
cfg.logger&.debug(
|
149
|
+
"Endpoint configured from ENV['AWS_ENDPOINT_URL']: #{endpoint}\n")
|
150
|
+
endpoint
|
151
|
+
end
|
152
|
+
|
153
|
+
def shared_config_endpoint(cfg)
|
154
|
+
service_id = cfg.api.metadata['serviceId'] || cfg.api.metadata['endpointPrefix']
|
155
|
+
return unless endpoint = Aws.shared_config.configured_endpoint(profile: cfg.profile, service_id: service_id)
|
156
|
+
|
157
|
+
cfg.logger&.debug(
|
158
|
+
"Endpoint configured from shared config(profile: #{cfg.profile}): #{endpoint}\n")
|
159
|
+
endpoint
|
160
|
+
end
|
161
|
+
|
162
|
+
# check region is a valid RFC host label
|
163
|
+
def validate_region!(region)
|
164
|
+
unless Seahorse::Util.host_label?(region)
|
165
|
+
raise Errors::InvalidRegionError
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
169
|
+
def handle_legacy_pseudo_regions(cfg)
|
170
|
+
region = cfg.region
|
171
|
+
new_region = region.gsub('fips-', '').gsub('-fips', '')
|
172
|
+
if region != new_region
|
173
|
+
warn("Legacy region #{region} was transformed to #{new_region}."\
|
174
|
+
'`use_fips_endpoint` config was set to true.')
|
175
|
+
cfg.override_config(:use_fips_endpoint, true)
|
176
|
+
cfg.override_config(:region, new_region)
|
177
|
+
end
|
178
|
+
end
|
179
|
+
# set a default endpoint in config using legacy (endpoints.json) resolver
|
180
|
+
def resolve_legacy_endpoint(cfg)
|
181
|
+
endpoint_prefix = cfg.api.metadata['endpointPrefix']
|
182
|
+
if cfg.respond_to?(:sts_regional_endpoints)
|
183
|
+
sts_regional = cfg.sts_regional_endpoints
|
184
|
+
end
|
185
|
+
|
186
|
+
Aws::Partitions::EndpointProvider.resolve(
|
187
|
+
cfg.region,
|
188
|
+
endpoint_prefix,
|
189
|
+
sts_regional,
|
190
|
+
{
|
191
|
+
dualstack: cfg.use_dualstack_endpoint,
|
192
|
+
fips: cfg.use_fips_endpoint
|
193
|
+
}
|
194
|
+
)
|
195
|
+
end
|
120
196
|
end
|
121
197
|
end
|
122
198
|
end
|
@@ -0,0 +1,217 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Aws
|
4
|
+
module Plugins
|
5
|
+
# @api private
|
6
|
+
class RequestCompression < Seahorse::Client::Plugin
|
7
|
+
DEFAULT_MIN_COMPRESSION_SIZE = 10_240
|
8
|
+
MIN_COMPRESSION_SIZE_LIMIT = 10_485_760
|
9
|
+
SUPPORTED_ENCODINGS = %w[gzip].freeze
|
10
|
+
CHUNK_SIZE = 1 * 1024 * 1024 # one MB
|
11
|
+
|
12
|
+
option(
|
13
|
+
:disable_request_compression,
|
14
|
+
default: false,
|
15
|
+
doc_type: 'Boolean',
|
16
|
+
docstring: <<-DOCS) do |cfg|
|
17
|
+
When set to 'true' the request body will not be compressed
|
18
|
+
for supported operations.
|
19
|
+
DOCS
|
20
|
+
resolve_disable_request_compression(cfg)
|
21
|
+
end
|
22
|
+
|
23
|
+
option(
|
24
|
+
:request_min_compression_size_bytes,
|
25
|
+
default: 10_240,
|
26
|
+
doc_type: 'Integer',
|
27
|
+
docstring: <<-DOCS) do |cfg|
|
28
|
+
The minimum size in bytes that triggers compression for request
|
29
|
+
bodies. The value must be non-negative integer value between 0
|
30
|
+
and 10485780 bytes inclusive.
|
31
|
+
DOCS
|
32
|
+
resolve_request_min_compression_size_bytes(cfg)
|
33
|
+
end
|
34
|
+
|
35
|
+
def after_initialize(client)
|
36
|
+
validate_disable_request_compression_input(client.config)
|
37
|
+
validate_request_min_compression_size_bytes_input(client.config)
|
38
|
+
end
|
39
|
+
|
40
|
+
def validate_disable_request_compression_input(cfg)
|
41
|
+
unless [true, false].include?(cfg.disable_request_compression)
|
42
|
+
raise ArgumentError,
|
43
|
+
'Must provide either `true` or `false` for the '\
|
44
|
+
'`disable_request_compression` configuration option.'
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def validate_request_min_compression_size_bytes_input(cfg)
|
49
|
+
value = Integer(cfg.request_min_compression_size_bytes)
|
50
|
+
unless value.between?(0, MIN_COMPRESSION_SIZE_LIMIT)
|
51
|
+
raise ArgumentError,
|
52
|
+
'Must provide a non-negative integer value between '\
|
53
|
+
'`0` and `10485760` bytes inclusive for the '\
|
54
|
+
'`request_min_compression_size_bytes` configuration option.'
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def add_handlers(handlers, _config)
|
59
|
+
# priority set to ensure compression happens BEFORE checksum
|
60
|
+
handlers.add(CompressionHandler, priority: 16, step: :build)
|
61
|
+
end
|
62
|
+
|
63
|
+
class << self
|
64
|
+
private
|
65
|
+
|
66
|
+
def resolve_disable_request_compression(cfg)
|
67
|
+
value = ENV['AWS_DISABLE_REQUEST_COMPRESSION'] ||
|
68
|
+
Aws.shared_config.disable_request_compression(profile: cfg.profile) ||
|
69
|
+
'false'
|
70
|
+
Aws::Util.str_2_bool(value)
|
71
|
+
end
|
72
|
+
|
73
|
+
def resolve_request_min_compression_size_bytes(cfg)
|
74
|
+
value = ENV['AWS_REQUEST_MIN_COMPRESSION_SIZE_BYTES'] ||
|
75
|
+
Aws.shared_config.request_min_compression_size_bytes(profile: cfg.profile) ||
|
76
|
+
DEFAULT_MIN_COMPRESSION_SIZE.to_s
|
77
|
+
Integer(value)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
# @api private
|
82
|
+
class CompressionHandler < Seahorse::Client::Handler
|
83
|
+
def call(context)
|
84
|
+
if should_compress?(context)
|
85
|
+
selected_encoding = request_encoding_selection(context)
|
86
|
+
if selected_encoding
|
87
|
+
if streaming?(context.operation.input)
|
88
|
+
process_streaming_compression(selected_encoding, context)
|
89
|
+
elsif context.http_request.body.size >= context.config.request_min_compression_size_bytes
|
90
|
+
process_compression(selected_encoding, context)
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
@handler.call(context)
|
95
|
+
end
|
96
|
+
|
97
|
+
private
|
98
|
+
|
99
|
+
def request_encoding_selection(context)
|
100
|
+
encoding_list = context.operation.request_compression['encodings']
|
101
|
+
encoding_list.find { |encoding| RequestCompression::SUPPORTED_ENCODINGS.include?(encoding) }
|
102
|
+
end
|
103
|
+
|
104
|
+
def update_content_encoding(encoding, context)
|
105
|
+
headers = context.http_request.headers
|
106
|
+
if headers['Content-Encoding']
|
107
|
+
headers['Content-Encoding'] += ',' + encoding
|
108
|
+
else
|
109
|
+
headers['Content-Encoding'] = encoding
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
def should_compress?(context)
|
114
|
+
context.operation.request_compression &&
|
115
|
+
!context.config.disable_request_compression
|
116
|
+
end
|
117
|
+
|
118
|
+
def streaming?(input)
|
119
|
+
if payload = input[:payload_member] # checking ref and shape
|
120
|
+
payload['streaming'] || payload.shape['streaming']
|
121
|
+
else
|
122
|
+
false
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
def process_compression(encoding, context)
|
127
|
+
case encoding
|
128
|
+
when 'gzip'
|
129
|
+
gzip_compress(context)
|
130
|
+
else
|
131
|
+
raise StandardError, "We currently do not support #{encoding} encoding"
|
132
|
+
end
|
133
|
+
update_content_encoding(encoding, context)
|
134
|
+
end
|
135
|
+
|
136
|
+
def gzip_compress(context)
|
137
|
+
compressed = StringIO.new
|
138
|
+
compressed.binmode
|
139
|
+
gzip_writer = Zlib::GzipWriter.new(compressed)
|
140
|
+
if context.http_request.body.respond_to?(:read)
|
141
|
+
update_in_chunks(gzip_writer, context.http_request.body)
|
142
|
+
else
|
143
|
+
gzip_writer.write(context.http_request.body)
|
144
|
+
end
|
145
|
+
gzip_writer.close
|
146
|
+
new_body = StringIO.new(compressed.string)
|
147
|
+
context.http_request.body = new_body
|
148
|
+
end
|
149
|
+
|
150
|
+
def update_in_chunks(compressor, io)
|
151
|
+
loop do
|
152
|
+
chunk = io.read(CHUNK_SIZE)
|
153
|
+
break unless chunk
|
154
|
+
|
155
|
+
compressor.write(chunk)
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
def process_streaming_compression(encoding, context)
|
160
|
+
case encoding
|
161
|
+
when 'gzip'
|
162
|
+
context.http_request.body = GzipIO.new(context.http_request.body)
|
163
|
+
else
|
164
|
+
raise StandardError, "We currently do not support #{encoding} encoding"
|
165
|
+
end
|
166
|
+
update_content_encoding(encoding, context)
|
167
|
+
end
|
168
|
+
|
169
|
+
# @api private
|
170
|
+
class GzipIO
|
171
|
+
def initialize(body)
|
172
|
+
@body = body
|
173
|
+
@buffer = ChunkBuffer.new
|
174
|
+
@gzip_writer = Zlib::GzipWriter.new(@buffer)
|
175
|
+
end
|
176
|
+
|
177
|
+
def read(length, buff = nil)
|
178
|
+
if @gzip_writer.closed?
|
179
|
+
# an empty string to signify an end as
|
180
|
+
# there will be nothing remaining to be read
|
181
|
+
StringIO.new('').read(length, buff)
|
182
|
+
return
|
183
|
+
end
|
184
|
+
|
185
|
+
chunk = @body.read(length)
|
186
|
+
if !chunk || chunk.empty?
|
187
|
+
# closing the writer will write one last chunk
|
188
|
+
# with a trailer (to be read from the @buffer)
|
189
|
+
@gzip_writer.close
|
190
|
+
else
|
191
|
+
# flush happens first to ensure that header fields
|
192
|
+
# are being sent over since write will override
|
193
|
+
@gzip_writer.flush
|
194
|
+
@gzip_writer.write(chunk)
|
195
|
+
end
|
196
|
+
|
197
|
+
StringIO.new(@buffer.last_chunk).read(length, buff)
|
198
|
+
end
|
199
|
+
end
|
200
|
+
|
201
|
+
# @api private
|
202
|
+
class ChunkBuffer
|
203
|
+
def initialize
|
204
|
+
@last_chunk = nil
|
205
|
+
end
|
206
|
+
|
207
|
+
attr_reader :last_chunk
|
208
|
+
|
209
|
+
def write(data)
|
210
|
+
@last_chunk = data
|
211
|
+
end
|
212
|
+
end
|
213
|
+
end
|
214
|
+
|
215
|
+
end
|
216
|
+
end
|
217
|
+
end
|
@@ -108,6 +108,7 @@ module Aws
|
|
108
108
|
credentials_provider: config.credentials,
|
109
109
|
signing_algorithm: scheme_name.to_sym,
|
110
110
|
uri_escape_path: !!!auth_scheme['disableDoubleEncoding'],
|
111
|
+
normalize_path: !!!auth_scheme['disableNormalizePath'],
|
111
112
|
unsigned_headers: %w[content-length user-agent x-amzn-trace-id]
|
112
113
|
)
|
113
114
|
rescue Aws::Sigv4::Errors::MissingCredentialsError
|