aws-sdk-core 3.175.0 → 3.184.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 +91 -0
- data/VERSION +1 -1
- data/lib/aws-sdk-core/credential_provider.rb +3 -0
- data/lib/aws-sdk-core/endpoints/matchers.rb +13 -9
- data/lib/aws-sdk-core/endpoints.rb +5 -1
- data/lib/aws-sdk-core/errors.rb +1 -1
- data/lib/aws-sdk-core/ini_parser.rb +7 -0
- data/lib/aws-sdk-core/param_validator.rb +2 -2
- 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/refreshing_credentials.rb +0 -6
- data/lib/aws-sdk-core/shared_config.rb +45 -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-sso/client.rb +16 -1
- data/lib/aws-sdk-sso/endpoint_provider.rb +27 -24
- data/lib/aws-sdk-sso.rb +1 -1
- data/lib/aws-sdk-ssooidc/client.rb +16 -1
- data/lib/aws-sdk-ssooidc/endpoint_provider.rb +30 -24
- data/lib/aws-sdk-ssooidc.rb +1 -1
- data/lib/aws-sdk-sts/client.rb +27 -2
- data/lib/aws-sdk-sts/client_api.rb +10 -0
- data/lib/aws-sdk-sts/types.rb +27 -2
- 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: c174e3e20f53c69aab8b23ec85ca75a84f7a9541b4a833da4cd7aabe5d08bdf9
|
4
|
+
data.tar.gz: eff5a3c9814ecfe8b4dbdd0eec1b72cb66f66d6d3ff514f89d06167f86dde081
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '09f540689c00d522c6a38026d284d660825faefcfd55b93337feeb226edd4b83e2c0c809206994630ee8dfa54505cc38802495117fb409d75aa482d1a22f3979'
|
7
|
+
data.tar.gz: fe803a96b1dab3ad3850ea180462f183baef5ad8055e6b38082e3be4965c32fd5f262431d49897d7dfd4ff0140f61e78ee772cc05385cd8865a075b0d93b0ca8
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,97 @@
|
|
1
1
|
Unreleased Changes
|
2
2
|
------------------
|
3
3
|
|
4
|
+
3.184.0 (2023-09-27)
|
5
|
+
------------------
|
6
|
+
|
7
|
+
* Feature - Change the `ServiceError` data member from read only to read/write.
|
8
|
+
|
9
|
+
3.183.1 (2023-09-25)
|
10
|
+
------------------
|
11
|
+
|
12
|
+
* Issue - Remove value inspection from param validation errors.
|
13
|
+
|
14
|
+
3.183.0 (2023-09-20)
|
15
|
+
------------------
|
16
|
+
|
17
|
+
* Feature - Updated Aws::SSOOIDC::Client with the latest API changes.
|
18
|
+
|
19
|
+
3.182.0 (2023-09-19)
|
20
|
+
------------------
|
21
|
+
|
22
|
+
* Feature - Updated Aws::SSOOIDC::Client with the latest API changes.
|
23
|
+
|
24
|
+
* Feature - Updated Aws::SSO::Client with the latest API changes.
|
25
|
+
|
26
|
+
3.181.1 (2023-09-14)
|
27
|
+
------------------
|
28
|
+
|
29
|
+
* Issue - Fix host label validation in endpoint matchers.
|
30
|
+
|
31
|
+
3.181.0 (2023-08-22)
|
32
|
+
------------------
|
33
|
+
|
34
|
+
* Feature - Add support for `on_chunk_received` callback.
|
35
|
+
|
36
|
+
3.180.3 (2023-08-09)
|
37
|
+
------------------
|
38
|
+
|
39
|
+
* Issue - Add support for sso-session names with whitespace configured by the CLI `aws sso configure` command (#2895).
|
40
|
+
|
41
|
+
3.180.2 (2023-08-07)
|
42
|
+
------------------
|
43
|
+
|
44
|
+
* Issue - Fix parsing of ini files with mixes of blank properties and nested configurations.
|
45
|
+
|
46
|
+
3.180.1 (2023-07-31)
|
47
|
+
------------------
|
48
|
+
|
49
|
+
* Issue - Remove checksums from default stubs (#2888).
|
50
|
+
|
51
|
+
3.180.0 (2023-07-25)
|
52
|
+
------------------
|
53
|
+
|
54
|
+
* Feature - Updated Aws::STS::Client with the latest API changes.
|
55
|
+
|
56
|
+
3.179.0 (2023-07-24)
|
57
|
+
------------------
|
58
|
+
|
59
|
+
* Feature - Add `checksum_validated` method to response.
|
60
|
+
|
61
|
+
3.178.0 (2023-07-11)
|
62
|
+
------------------
|
63
|
+
|
64
|
+
* Feature - Updated Aws::STS::Client with the latest API changes.
|
65
|
+
|
66
|
+
* Feature - Updated Aws::SSOOIDC::Client with the latest API changes.
|
67
|
+
|
68
|
+
* Feature - Updated Aws::SSO::Client with the latest API changes.
|
69
|
+
|
70
|
+
* 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.
|
71
|
+
|
72
|
+
3.177.0 (2023-07-06)
|
73
|
+
------------------
|
74
|
+
|
75
|
+
* Feature - Updated Aws::STS::Client with the latest API changes.
|
76
|
+
|
77
|
+
* Feature - Updated Aws::SSOOIDC::Client with the latest API changes.
|
78
|
+
|
79
|
+
* Feature - Updated Aws::SSO::Client with the latest API changes.
|
80
|
+
|
81
|
+
* Feature - Add support for Request Compression.
|
82
|
+
|
83
|
+
3.176.1 (2023-06-29)
|
84
|
+
------------------
|
85
|
+
|
86
|
+
* Issue - Fix signing for S3/S3 Control and `aws-crt` gem for certain object keys (#2849).
|
87
|
+
|
88
|
+
* Issue - Ensure `SSOCredentials` `#expiration` is a `Time` (#2874)
|
89
|
+
|
90
|
+
3.176.0 (2023-06-28)
|
91
|
+
------------------
|
92
|
+
|
93
|
+
* Feature - Add :expiration accessor to `CredentialProvider` and do not refresh credentials when checking expiration (#2872).
|
94
|
+
|
4
95
|
3.175.0 (2023-06-15)
|
5
96
|
------------------
|
6
97
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
3.
|
1
|
+
3.184.0
|
@@ -79,11 +79,11 @@ module Aws
|
|
79
79
|
return false if value.empty?
|
80
80
|
|
81
81
|
if allow_sub_domains
|
82
|
-
labels = value.split('.')
|
82
|
+
labels = value.split('.', -1)
|
83
83
|
return labels.all? { |l| valid_host_label?(l) }
|
84
84
|
end
|
85
85
|
|
86
|
-
value =~ /\A(?!-)[a-zA-Z0-9-]{1,63}(?<!-)\z/
|
86
|
+
!!(value =~ /\A(?!-)[a-zA-Z0-9-]{1,63}(?<!-)\z/)
|
87
87
|
end
|
88
88
|
|
89
89
|
# AWS
|
@@ -114,13 +114,17 @@ module Aws
|
|
114
114
|
|
115
115
|
# aws.isVirtualHostableS3Bucket(value: string, allowSubDomains: bool) bool
|
116
116
|
def self.aws_virtual_hostable_s3_bucket?(value, allow_sub_domains = false)
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
117
|
+
return false if value.empty?
|
118
|
+
|
119
|
+
if allow_sub_domains
|
120
|
+
labels = value.split('.', -1)
|
121
|
+
return labels.all? { |l| aws_virtual_hostable_s3_bucket?(l) }
|
122
|
+
end
|
123
|
+
|
124
|
+
# must be between 3 and 63 characters long, no uppercase
|
125
|
+
value =~ /\A(?!-)[a-z0-9-]{3,63}(?<!-)\z/ &&
|
126
|
+
# not an IP address
|
127
|
+
value !~ /(\d+\.){3}\d+/
|
124
128
|
end
|
125
129
|
end
|
126
130
|
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' }
|
data/lib/aws-sdk-core/errors.rb
CHANGED
@@ -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] ||= {}
|
@@ -6,7 +6,7 @@ module Aws
|
|
6
6
|
|
7
7
|
include Seahorse::Model::Shapes
|
8
8
|
|
9
|
-
EXPECTED_GOT =
|
9
|
+
EXPECTED_GOT = 'expected %s to be %s, got class %s instead.'
|
10
10
|
|
11
11
|
# @param [Seahorse::Model::Shapes::ShapeRef] rules
|
12
12
|
# @param [Hash] params
|
@@ -230,7 +230,7 @@ module Aws
|
|
230
230
|
end
|
231
231
|
|
232
232
|
def expected_got(context, expected, got)
|
233
|
-
EXPECTED_GOT % [context, expected, got.
|
233
|
+
EXPECTED_GOT % [context, expected, got.class.name]
|
234
234
|
end
|
235
235
|
|
236
236
|
end
|
@@ -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
|