aws-sdk-core 3.260.0 → 3.271.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.
Files changed (40) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +85 -0
  3. data/VERSION +1 -1
  4. data/lib/aws-sdk-core/json/error_handler.rb +1 -1
  5. data/lib/aws-sdk-core/log/formatter.rb +3 -2
  6. data/lib/aws-sdk-core/log/param_filter.rb +73 -9
  7. data/lib/aws-sdk-core/login_credentials.rb +21 -6
  8. data/lib/aws-sdk-core/pageable_response.rb +8 -1
  9. data/lib/aws-sdk-core/plugins/checksum_algorithm.rb +53 -20
  10. data/lib/aws-sdk-core/plugins/retries/clock_skew.rb +8 -9
  11. data/lib/aws-sdk-core/plugins/retries/retry_quota.rb +3 -9
  12. data/lib/aws-sdk-core/plugins/retry_errors.rb +36 -49
  13. data/lib/aws-sdk-core/plugins/stub_responses.rb +1 -1
  14. data/lib/aws-sdk-core/plugins/user_agent.rb +2 -1
  15. data/lib/aws-sdk-core/response.rb +23 -0
  16. data/lib/aws-sdk-core/rest/response/headers.rb +4 -3
  17. data/lib/aws-sdk-core/rpc_v2/error_handler.rb +1 -1
  18. data/lib/aws-sdk-core/xml/error_handler.rb +1 -1
  19. data/lib/aws-sdk-core.rb +1 -0
  20. data/lib/aws-sdk-signin/client.rb +503 -75
  21. data/lib/aws-sdk-signin/client_api.rb +218 -3
  22. data/lib/aws-sdk-signin/endpoints.rb +55 -0
  23. data/lib/aws-sdk-signin/errors.rb +67 -0
  24. data/lib/aws-sdk-signin/types.rb +611 -132
  25. data/lib/aws-sdk-signin.rb +2 -2
  26. data/lib/aws-sdk-sso/client.rb +7 -6
  27. data/lib/aws-sdk-sso.rb +1 -1
  28. data/lib/aws-sdk-ssooidc/client.rb +7 -6
  29. data/lib/aws-sdk-ssooidc.rb +1 -1
  30. data/lib/aws-sdk-sts/client.rb +240 -122
  31. data/lib/aws-sdk-sts/client_api.rb +84 -0
  32. data/lib/aws-sdk-sts/errors.rb +57 -0
  33. data/lib/aws-sdk-sts/types.rb +461 -141
  34. data/lib/aws-sdk-sts.rb +1 -1
  35. data/lib/seahorse/client/configuration.rb +68 -1
  36. data/lib/seahorse/client/h2/connection.rb +9 -1
  37. data/lib/seahorse/client/http/request.rb +19 -0
  38. data/lib/seahorse/client/net_http/handler.rb +1 -1
  39. data/lib/seahorse/model/shapes.rb +6 -6
  40. metadata +2 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fdf3489f3be6d6fe071ddf109dc612c7049e906ef12f425d009e7a58bfc746bb
4
- data.tar.gz: a0cfa6a42abe97a7cf38238ab4ad6b3a29aabd5d9f6f18532460595a9af9aeac
3
+ metadata.gz: '0884b02f7eb7e9d2209dab57fb3112df29e3f327bf63946e915af04d922b2306'
4
+ data.tar.gz: e28e69ee0157dc6fa64655fc2fa8995b5c35a76636a6bc195a0b109b026cba61
5
5
  SHA512:
6
- metadata.gz: bd1b2e75d6997cd9474986a6dffb87adee2d9aecfcdaf85f70ed9633a3cb4bb21e30bc11faea17e68b945a6aa180c23e900ed95c256b68f56f09cdd86f35d974
7
- data.tar.gz: 6f126a87838230567b55780f57e6ad85019480cea159b9b7f504ed9309d8e7675adf0232ec60fdaeb583b4117aadab4fa8e36fed111ec42a0026f3e53c60df13
6
+ metadata.gz: b57d560b0d2d4956a8a48a3b188ea99aae4fedf43cead664fb91fb336537e66b7e245ac4e78daa94218c9f1ef1d52afd3ffd9ff64c5eb16a6787d16ad3cb450a
7
+ data.tar.gz: 5ddc3620ad00ef4f98ddb1f5b82896f501b3afc07a5518bee1c78fbb6a9e24332521a34ad04a32ad5744d894ad54f0354d695d501d9ff77bb9653e16e63b6d68
data/CHANGELOG.md CHANGED
@@ -1,6 +1,91 @@
1
1
  Unreleased Changes
2
2
  ------------------
3
3
 
4
+ 3.271.0 (2026-11-19)
5
+ ------------------
6
+
7
+ * Feature - Updated Aws::STS::Client with the latest API changes.
8
+
9
+ * Feature - AWS STS adds GetScopedCredentials and expands Trusted Identity Propagation (TIP) to IAM federation and IAM Roles Anywhere. GetScopedCredentials reduces an existing session's permissions and duration. TIP carries verified user or workload identity for authorization and CloudTrail auditing.
10
+
11
+ 3.270.0 (2026-11-18)
12
+ ------------------
13
+
14
+ * Feature - Updated Aws::Signin::Client with the latest API changes.
15
+
16
+ * Feature - These APIs enable customers and administrators to list, view, and revoke AWS Sign-In Sessions programmatically using the AWS CLI and SDKs, providing greater visibility and control over authenticated access.
17
+
18
+ * Feature - Back off on retries of the Kinesis `ReceiveQueueRecords` and `ReceiveDeadLetterQueueRecords` long polling operations even when the retry quota is depleted.
19
+
20
+ * Feature - Seahorse::Client::Configuration no longer generate real Ruby Struct at runtime.
21
+
22
+ 3.269.0 (2026-11-16)
23
+ ------------------
24
+
25
+ * Feature - Reduce memory usage of loaded service APIs by allocating shape metadata Hashes on first write.
26
+
27
+ * Feature - Reuse the chunk size header of full chunks when streaming request bodies with checksum trailers.
28
+
29
+ 3.268.0 (2026-11-11)
30
+ ------------------
31
+
32
+ * Feature - Reuse read buffers to reduce allocations when calculating request checksums sent in headers.
33
+
34
+ 3.267.0 (2026-11-10)
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 - Updated Aws::Signin::Client with the latest API changes.
44
+
45
+ * Feature - AWS SDK clients now use `standard` retry mode by default, providing consistent retry quotas and backoff behavior across AWS services. To continue using the previous behavior, set the client's `retry_mode` to `legacy` or set `AWS_RETRY_MODE=legacy`. The `AWS_NEW_RETRIES_2026` environment variable is no longer used.
46
+
47
+ 3.266.0 (2026-11-09)
48
+ ------------------
49
+
50
+ * Feature - Updated Aws::Signin::Client with the latest API changes.
51
+
52
+ * Feature - Adds the CreateBearerToken API, which exchanges your IAM credentials for a bearer token that can be used to access supported AWS services.
53
+
54
+ * Feature - Reduce memory allocations when streaming request bodies with checksum trailers while preserving compatibility with custom IO bodies.
55
+
56
+ 3.265.0 (2026-11-06)
57
+ ------------------
58
+
59
+ * Feature - Improve model-aware filtering of nested request parameters and sensitivity detection for nested collections.
60
+
61
+ 3.264.0 (2026-11-04)
62
+ ------------------
63
+
64
+ * Feature - Support refreshing login credentials in the cached sign-in region, falling back to the configured region when missing or empty.
65
+
66
+ * Issue - Fix clock skew correction for long-running requests and slow response downloads by using the time response headers are received.
67
+
68
+ 3.263.0 (2026-10-29)
69
+ ------------------
70
+
71
+ * Feature - Reduce object allocation overhead for SDK responses. SDK clients now return `Aws::Response`, a subclass of `Seahorse::Client::Response`.
72
+
73
+ * Issue - Verify the server certificate hostname for `AsyncClient` HTTP/2 connections when `ssl_verify_peer` is enabled. Connections now fail if the server certificate does not match the endpoint hostname.
74
+
75
+ 3.262.0 (2026-10-28)
76
+ ------------------
77
+
78
+ * Feature - Improve User-Agent framework detection with literal matching of configured framework names.
79
+
80
+ * Issue - Fix service error parsing and response header-map extraction by matching prefixes literally. Custom models that relied on regex matching must use literal prefixes.
81
+
82
+ 3.261.0 (2026-10-26)
83
+ ------------------
84
+
85
+ * Feature - Updated Aws::Signin::Client with the latest API changes.
86
+
87
+ * Feature - Adds support for the OAuth 2.0 Token Exchange grant (RFC 8693), enabling applications to exchange identity provider issued JSON Web Tokens (JWTs) for short-lived OAuth access tokens to access supported AWS services without managing separate AWS credentials.
88
+
4
89
  3.260.0 (2026-10-21)
5
90
  ------------------
6
91
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 3.260.0
1
+ 3.271.0
@@ -58,7 +58,7 @@ module Aws
58
58
 
59
59
  def remove_prefix(error_code, context)
60
60
  if (prefix = context.config.api.metadata['errorPrefix'])
61
- error_code.sub(/^#{prefix}/, '')
61
+ error_code.delete_prefix(prefix)
62
62
  else
63
63
  error_code
64
64
  end
@@ -132,8 +132,9 @@ module Aws
132
132
 
133
133
  def _request_params(response)
134
134
  params = response.context.params
135
- type = response.context.operation.input.shape.struct_class
136
- @param_formatter.summarize(@param_filter.filter(params, type))
135
+ operation = response.context.operation
136
+ ref = operation && operation.input
137
+ @param_formatter.summarize(@param_filter.filter(params, ref))
137
138
  end
138
139
 
139
140
  def _time(response)
@@ -24,7 +24,68 @@ module Aws
24
24
  @additional_filters = options[:filter] || []
25
25
  end
26
26
 
27
+ # Returns a copy with sensitive values replaced by "[FILTERED]".
28
+ #
29
+ # Uses generated SENSITIVE lists to choose which members to redact.
30
+ # Nested request hashes also use the global list for backwards compatibility.
31
+ # A ShapeRef preserves model types while filtering nested request parameters.
32
+ # Structure classes are also accepted for Structure#to_s and older callers.
33
+ #
34
+ # @param [Hash, Struct, Array, Object] values
35
+ # @param [Seahorse::Model::Shapes::ShapeRef, Class, nil] type
27
36
  def filter(values, type)
37
+ return filter_ref(values, type, root: true) if type.is_a?(Seahorse::Model::Shapes::ShapeRef)
38
+
39
+ filter_by_class(values, type)
40
+ end
41
+
42
+ private
43
+
44
+ def filter_ref(value, ref, root: false)
45
+ return filter_by_class(value, value.class) unless ref
46
+
47
+ shape = ref.shape
48
+ case shape
49
+ when Seahorse::Model::Shapes::StructureShape
50
+ if value.is_a?(Hash) || value.is_a?(Struct)
51
+ return filter_struct(
52
+ value, shape.struct_class, shape,
53
+ use_global_filters: !root && value.is_a?(Hash)
54
+ )
55
+ end
56
+ when Seahorse::Model::Shapes::ListShape
57
+ return value.map { |v| filter_ref(v, shape.member) } if value.is_a?(Array)
58
+ when Seahorse::Model::Shapes::MapShape
59
+ return filter_map(value, shape) if value.is_a?(Hash)
60
+ when Seahorse::Model::Shapes::DocumentShape, nil
61
+ return filter_by_class(value, value.class)
62
+ else
63
+ return value
64
+ end
65
+
66
+ filter_by_class(value, value.class)
67
+ end
68
+
69
+ def filter_map(values, shape)
70
+ filtered = {}
71
+ values.each_pair do |key, value|
72
+ filtered[key] =
73
+ if @enabled && @additional_filters.include?(key)
74
+ '[FILTERED]'
75
+ else
76
+ filter_ref(value, shape.value)
77
+ end
78
+ end
79
+ filtered
80
+ end
81
+
82
+ def member_ref(shape, key)
83
+ return unless key.is_a?(Symbol) || key.is_a?(String)
84
+
85
+ shape.member(key) if shape.member?(key)
86
+ end
87
+
88
+ def filter_by_class(values, type)
28
89
  case values
29
90
  when Struct then filter_struct(values, type)
30
91
  when Hash then filter_hash(values, type)
@@ -33,18 +94,19 @@ module Aws
33
94
  end
34
95
  end
35
96
 
36
- private
37
-
38
- def filter_struct(values, type)
39
- if values.class.include? Aws::Structure::Union
97
+ def filter_struct(values, type, shape = nil, use_global_filters: false)
98
+ if values.is_a?(Struct) && values.class.include?(Aws::Structure::Union)
40
99
  values = { values.member => values.value }
41
100
  end
42
- filter_hash(values, type)
101
+ filter_hash(values, type, shape, use_global_filters: use_global_filters)
43
102
  end
44
103
 
45
- def filter_hash(values, type)
46
- if type.const_defined?('SENSITIVE')
104
+ def filter_hash(values, type, shape = nil, use_global_filters: false)
105
+ if type && type.const_defined?(:SENSITIVE)
47
106
  filters = type::SENSITIVE + @additional_filters
107
+ # Nested hashes previously used the global list. Keep that protection
108
+ # alongside modeled sensitivity when following their shape references.
109
+ filters += SENSITIVE if use_global_filters
48
110
  else
49
111
  # Support backwards compatibility (new core + old service)
50
112
  filters = SENSITIVE + @additional_filters
@@ -54,15 +116,17 @@ module Aws
54
116
  values.each_pair do |key, value|
55
117
  filtered[key] = if @enabled && filters.include?(key)
56
118
  '[FILTERED]'
119
+ elsif shape
120
+ filter_ref(value, member_ref(shape, key))
57
121
  else
58
- filter(value, value.class)
122
+ filter_by_class(value, value.class)
59
123
  end
60
124
  end
61
125
  filtered
62
126
  end
63
127
 
64
128
  def filter_array(values, type)
65
- values.map { |value| filter(value, value.class) }
129
+ values.map { |value| filter_by_class(value, value.class) }
66
130
  end
67
131
 
68
132
  end
@@ -12,7 +12,9 @@ module Aws
12
12
  # ec2 = Aws::EC2::Client.new(credentials: login_credentials)
13
13
  #
14
14
  # If you omit the `:client` option, a new {Aws::Signin::Client} object will
15
- # be constructed with additional options that were provided.
15
+ # be constructed with additional options that were provided. When the cached
16
+ # token records a different `signInRegion`, a client for that region is
17
+ # constructed the same way and used to refresh.
16
18
  class LoginCredentials
17
19
  include CredentialProvider
18
20
  include RefreshingCredentials
@@ -23,22 +25,26 @@ module Aws
23
25
  # PowerShell automatically.
24
26
  #
25
27
  # @option options [Signin::Client] :client Optional `Signin::Client`.
26
- # If not provided, a client will be constructed.
28
+ # If not provided, a client will be constructed. A provided client is
29
+ # used for every refresh, so it must be configured for the region the
30
+ # login token was issued in.
27
31
  def initialize(options = {})
28
32
  raise ArgumentError, 'Missing login_session' unless options[:login_session]
29
33
 
30
34
  @login_session = options.delete(:login_session)
31
35
  @client = options[:client]
32
36
  unless @client
33
- client_opts = options.reject { |key, _| CLIENT_EXCLUDE_OPTIONS.include?(key) }
34
- @client = Signin::Client.new(client_opts.merge(credentials: nil))
37
+ @client_opts = options.reject { |key, _| CLIENT_EXCLUDE_OPTIONS.include?(key) }.merge(credentials: nil)
38
+ @client = Signin::Client.new(@client_opts)
35
39
  end
36
40
  @metrics = ['CREDENTIALS_LOGIN']
37
41
  @async_refresh = true
38
42
  super
39
43
  end
40
44
 
41
- # @return [Signin::Client]
45
+ # @return [Signin::Client] The client built from the given options. A refresh
46
+ # uses a client for another region when the cached token records a different
47
+ # `signInRegion`.
42
48
  attr_reader :client
43
49
 
44
50
  private
@@ -138,7 +144,7 @@ module Aws
138
144
  refresh_token: token_json['refreshToken']
139
145
  }
140
146
  }
141
- req = @client.build_request(:create_o_auth_2_token, options)
147
+ req = signin_client(token_json['signInRegion']).build_request(:create_o_auth_2_token, options)
142
148
  endpoint_params = Aws::Signin::EndpointParameters.create(req.context.config)
143
149
  endpoint = req.context.config.endpoint_provider.resolve_endpoint(endpoint_params)
144
150
  endpoint = URI.join(endpoint.url, @client.config.api.operation(:create_o_auth_2_token).http_request_uri).to_s
@@ -146,6 +152,15 @@ module Aws
146
152
  req.send_request
147
153
  end
148
154
 
155
+ # Refresh tokens can only be redeemed in the region they were issued in,
156
+ # which the login tool records in the cached token as `signInRegion`.
157
+ def signin_client(signin_region)
158
+ return @client if @client_opts.nil? || signin_region.to_s.empty? || signin_region == @client.config.region
159
+
160
+ @signin_region_clients ||= {}
161
+ @signin_region_clients[signin_region] ||= Signin::Client.new(@client_opts.merge(region: signin_region))
162
+ end
163
+
149
164
  def dpop_proof(dpop_key, endpoint)
150
165
  # Load private key from cached token file
151
166
  private_key = OpenSSL::PKey.read(dpop_key)
@@ -46,10 +46,16 @@ module Aws
46
46
  # puts response.contents.map(&:key)
47
47
  # end
48
48
  #
49
+ # Every client response supports these methods. A response from an
50
+ # operation that does not paginate has a single page, so `last_page?`
51
+ # returns `true` and `each` yields only that response.
52
+ #
49
53
  module PageableResponse
50
54
 
55
+ # Adds paging methods when needed and resets cached paging state.
56
+ # An {Aws::Response} already has the methods through its class.
51
57
  def self.apply(base)
52
- base.extend Extension
58
+ base.extend Extension unless Extension === base
53
59
  base.instance_variable_set(:@last_page, nil)
54
60
  base.instance_variable_set(:@more_results, nil)
55
61
  base
@@ -217,5 +223,6 @@ module Aws
217
223
  end
218
224
 
219
225
  end
226
+
220
227
  end
221
228
  end
@@ -331,13 +331,15 @@ module Aws
331
331
  headers[algorithm_header] = checksum_properties[:algorithm]
332
332
  end
333
333
 
334
+ return unless %w[header trailer].include?(checksum_properties[:in])
335
+
336
+ body = context.http_request.body
337
+ buffer_enabled = context.http_request.buffer_supported? if body.respond_to?(:read)
334
338
  case checksum_properties[:in]
335
339
  when 'header'
336
- apply_request_checksum(context, headers, checksum_properties)
340
+ apply_request_checksum(context, headers, checksum_properties, buffer_enabled)
337
341
  when 'trailer'
338
- apply_request_trailer_checksum(context, headers, checksum_properties)
339
- else
340
- # nothing
342
+ apply_request_trailer_checksum(context, headers, checksum_properties, buffer_enabled)
341
343
  end
342
344
  end
343
345
 
@@ -355,19 +357,20 @@ module Aws
355
357
  context[:skip_trailer_checksums]
356
358
  end
357
359
 
358
- def apply_request_checksum(context, headers, checksum_properties)
360
+ def apply_request_checksum(context, headers, checksum_properties, buffer_enabled)
359
361
  header_name = checksum_properties[:name]
360
362
  headers[header_name] = calculate_checksum(
361
363
  checksum_properties[:algorithm],
362
- context.http_request.body
364
+ context.http_request.body,
365
+ buffer_enabled
363
366
  )
364
367
  end
365
368
 
366
- def calculate_checksum(algorithm, body)
369
+ def calculate_checksum(algorithm, body, buffer_enabled)
367
370
  digest = ChecksumAlgorithm.digest_for_algorithm(algorithm)
368
371
  if body.respond_to?(:read)
369
372
  body.rewind
370
- update_in_chunks(digest, body)
373
+ update_in_chunks(digest, body, buffer_enabled)
371
374
  body.rewind
372
375
  else
373
376
  digest.update(body)
@@ -375,17 +378,29 @@ module Aws
375
378
  digest.base64digest
376
379
  end
377
380
 
378
- def update_in_chunks(digest, io)
379
- loop do
380
- chunk = io.read(CHECKSUM_CHUNK_SIZE)
381
- break unless chunk
381
+ def update_in_chunks(digest, io, buffer_enabled)
382
+ if buffer_enabled
383
+ update_in_chunks_with_buffer(digest, io)
384
+ else
385
+ update_in_chunks_without_buffer(digest, io)
386
+ end
387
+ io.rewind
388
+ end
382
389
 
390
+ def update_in_chunks_with_buffer(digest, io)
391
+ buffer = ''.b
392
+ while (chunk = io.read(CHECKSUM_CHUNK_SIZE, buffer))
383
393
  digest.update(chunk)
384
394
  end
385
- io.rewind
386
395
  end
387
396
 
388
- def apply_request_trailer_checksum(context, headers, checksum_properties)
397
+ def update_in_chunks_without_buffer(digest, io)
398
+ while (chunk = io.read(CHECKSUM_CHUNK_SIZE))
399
+ digest.update(chunk)
400
+ end
401
+ end
402
+
403
+ def apply_request_trailer_checksum(context, headers, checksum_properties, buffer_enabled)
389
404
  location_name = checksum_properties[:name]
390
405
 
391
406
  # set required headers
@@ -410,6 +425,7 @@ module Aws
410
425
  context.http_request.body =
411
426
  AwsChunkedTrailerDigestIO.new(
412
427
  io: context.http_request.body,
428
+ buffer_enabled: buffer_enabled,
413
429
  algorithm: checksum_properties[:algorithm],
414
430
  location_name: location_name
415
431
  )
@@ -484,6 +500,7 @@ module Aws
484
500
  HEX_BASE = 16
485
501
 
486
502
  def initialize(options = {})
503
+ buffer_enabled = options.delete(:buffer_enabled) || false
487
504
  @io = options.delete(:io)
488
505
  @io.rewind if @io.respond_to?(:rewind)
489
506
  @location_name = options.delete(:location_name)
@@ -492,6 +509,9 @@ module Aws
492
509
  @chunk_size = Thread.current[:net_http_override_body_stream_chunk] || DEFAULT_TRAILER_CHUNK_SIZE
493
510
  @overhead_bytes = calculate_overhead(@chunk_size)
494
511
  @base_chunk_size = @chunk_size - @overhead_bytes
512
+ @full_chunk_size_hex = @base_chunk_size.to_s(HEX_BASE).freeze
513
+ @chunk = ''.b
514
+ @read_chunk = method(buffer_enabled ? :read_chunk_with_buffer : :read_chunk_without_buffer)
495
515
  @encoded_buffer = +''
496
516
  @eof = false
497
517
  end
@@ -502,7 +522,7 @@ module Aws
502
522
  n_full_chunks = orig_body_size / @base_chunk_size
503
523
  partial_bytes = orig_body_size % @base_chunk_size
504
524
 
505
- full_chunk_overhead = @base_chunk_size.to_s(HEX_BASE).size + CHUNK_OVERHEAD
525
+ full_chunk_overhead = @full_chunk_size_hex.bytesize + CHUNK_OVERHEAD
506
526
  chunked_body_size = n_full_chunks * (@base_chunk_size + full_chunk_overhead)
507
527
  unless partial_bytes.zero?
508
528
  chunked_body_size += partial_bytes.to_s(HEX_BASE).size + partial_bytes + CHUNK_OVERHEAD
@@ -527,8 +547,9 @@ module Aws
527
547
 
528
548
  fill_encoded_buffer(length)
529
549
 
530
- if length
531
- output_buffer << @encoded_buffer.slice!(0, length)
550
+ if length && length < @encoded_buffer.bytesize
551
+ output_buffer << @encoded_buffer.byteslice(0, length)
552
+ @encoded_buffer = @encoded_buffer.byteslice(length, @encoded_buffer.bytesize - length)
532
553
  else
533
554
  output_buffer << @encoded_buffer
534
555
  @encoded_buffer.clear
@@ -547,21 +568,33 @@ module Aws
547
568
  chunk_size.to_s(HEX_BASE).size + CHUNK_OVERHEAD
548
569
  end
549
570
 
571
+ def read_chunk_with_buffer
572
+ @io.read(@base_chunk_size, @chunk)
573
+ end
574
+
575
+ def read_chunk_without_buffer
576
+ @io.read(@base_chunk_size)
577
+ end
578
+
550
579
  def fill_encoded_buffer(required_length)
551
580
  return if required_length && @encoded_buffer.bytesize >= required_length
552
581
 
553
582
  while !@eof && fill_data?(required_length)
554
- chunk = @io.read(@base_chunk_size)
583
+ chunk = @read_chunk.call
555
584
  if chunk && !chunk.empty?
556
585
  @digest.update(chunk)
557
- @encoded_buffer << "#{chunk.bytesize.to_s(HEX_BASE)}\r\n#{chunk}\r\n"
586
+ @encoded_buffer << chunk_size_hex(chunk.bytesize) << "\r\n" << chunk << "\r\n"
558
587
  else
559
- @encoded_buffer << "0\r\n#{trailer_string}\r\n\r\n"
588
+ @encoded_buffer << "0\r\n" << trailer_string << "\r\n\r\n"
560
589
  @eof = true
561
590
  end
562
591
  end
563
592
  end
564
593
 
594
+ def chunk_size_hex(bytesize)
595
+ bytesize == @base_chunk_size ? @full_chunk_size_hex : bytesize.to_s(HEX_BASE)
596
+ end
597
+
565
598
  def trailer_string
566
599
  { @location_name => @digest.base64digest }.map { |k, v| "#{k}:#{v}" }.join("\r\n")
567
600
  end
@@ -39,7 +39,7 @@ module Aws
39
39
 
40
40
  # Whether a response indicates skew large enough to warrant a retry; records nothing.
41
41
  # @param context [Seahorse::Client::RequestContext]
42
- # @param sent_at [Time, nil] raw (pre-skew) send time, for the midpoint calculation
42
+ # @param sent_at [Time, nil] raw (pre-skew) send time, to discard slow requests
43
43
  def clock_skewed?(context, sent_at = nil)
44
44
  candidate = candidate_skew(context, sent_at)
45
45
  !!candidate && candidate.abs > CLOCK_SKEW_THRESHOLD
@@ -47,7 +47,7 @@ module Aws
47
47
 
48
48
  # Called on every response; records the skew candidate when one can be computed.
49
49
  # @param context [Seahorse::Client::RequestContext]
50
- # @param sent_at [Time, nil] raw (pre-skew) send time, for the midpoint calculation
50
+ # @param sent_at [Time, nil] raw (pre-skew) send time, to discard slow requests
51
51
  def update_clock_correction(context, sent_at = nil)
52
52
  candidate = candidate_skew(context, sent_at)
53
53
  return if candidate.nil?
@@ -74,23 +74,22 @@ module Aws
74
74
  private
75
75
 
76
76
  # Single source of truth for skew computation; returns a Float skew or nil.
77
+ # The candidate is the server Date minus the time the response headers were
78
+ # received (the current time if that was not recorded).
77
79
  # @param context [Seahorse::Client::RequestContext]
78
- # @param sent_at [Time, nil] raw (pre-skew) send time; midpoint when present, else server - now
80
+ # @param sent_at [Time, nil] raw (pre-skew) send time; used only to discard slow requests
79
81
  # @return [Float, nil]
80
82
  def candidate_skew(context, sent_at = nil)
81
83
  response = context.http_response
82
84
  server_time = server_time(response)
83
85
  # No candidate if the Date header is absent/unparseable or the response was cached.
84
86
  return nil if server_time.nil? || response.headers['age']
85
- return server_time - Time.now.utc unless sent_at
86
87
 
87
- received_at = Time.now.utc
88
- elapsed = received_at - sent_at
88
+ received_at = context.metadata[:response_received_at] || Time.now.utc
89
89
  # Discard if the request was too slow for the measurement to be trusted.
90
- return nil if elapsed > MAX_TRUSTED_REQUEST_DURATION
90
+ return nil if sent_at && received_at - sent_at > MAX_TRUSTED_REQUEST_DURATION
91
91
 
92
- # Midpoint formula (NTP clock offset, RFC 5905 section 8).
93
- server_time - (sent_at + (elapsed / 2.0))
92
+ server_time - received_at
94
93
  end
95
94
 
96
95
  ##
@@ -9,10 +9,8 @@ module Aws
9
9
  class RetryQuota
10
10
  INITIAL_RETRY_TOKENS = 500
11
11
  RETRY_COST = 14
12
- LEGACY_RETRY_COST = 5 # TODO: Remove when new retries become default
13
12
  NO_RETRY_INCREMENT = 1
14
13
  THROTTLING_RETRY_COST = 5
15
- TIMEOUT_RETRY_COST = 10 # TODO: Remove when new retries become default
16
14
 
17
15
  def initialize(opts = {})
18
16
  @mutex = Mutex.new
@@ -26,12 +24,8 @@ module Aws
26
24
  # @return [Integer] The amount of capacity checked out
27
25
  def checkout_capacity(error_inspector)
28
26
  @mutex.synchronize do
29
- # TODO: Remove gate and keep only the new_retries branch
30
- capacity_amount = if RetryErrors.new_retries?
31
- error_inspector.throttling_error? ? THROTTLING_RETRY_COST : RETRY_COST
32
- else
33
- error_inspector.networking? ? TIMEOUT_RETRY_COST : LEGACY_RETRY_COST
34
- end
27
+ capacity_amount =
28
+ error_inspector.throttling_error? ? THROTTLING_RETRY_COST : RETRY_COST
35
29
 
36
30
  # unable to acquire capacity
37
31
  return 0 if capacity_amount > @available_capacity
@@ -43,7 +37,7 @@ module Aws
43
37
 
44
38
  # capacity_amount refers to the amount of capacity requested from
45
39
  # the last retry. It can either be RETRY_COST,
46
- # THROTTLING_RETRY_COST/TIMEOUT_RETRY_COST, or unset.
40
+ # THROTTLING_RETRY_COST, or unset.
47
41
  def release(capacity_amount)
48
42
  # Implementation note: The release() method is called for
49
43
  # every API call. In the common case where the request is