aws-sdk-core 3.121.1 → 3.121.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6045e01344ede12d88ef25ca9815ce3b267a0b08335e9f97753e5fd357f05a83
4
- data.tar.gz: f0e783887c602e49acfa7837f0434a39936b786325846553e5db075f4c48b416
3
+ metadata.gz: 4b9f3fb30de8f9941d6f38fba87b19a9a68885fa51f28604481686e9dac1848c
4
+ data.tar.gz: 258e63026024946722a4bbdaaf34d91b633857a9b0310d735547e1cadfbefd51
5
5
  SHA512:
6
- metadata.gz: 9ffa8d2716f3ecc99d5d52139811ef43d82250350be7b8db687bfa9cc25c8d046be6102f62dce196e9b85394c0b0c1db9df8356ff106c793ab232118e26682b2
7
- data.tar.gz: 3c14caf81ef5425d0d5ee7f1b1d3f1dab3df5dfdb5673cbbe023120cef954fde6cdbf26e52cfcf74a62ef3863d14cf5d3dad6105007fc15960f8e60ab5b2a1a9
6
+ metadata.gz: 6706b957d3f7649d5886e388fefb261b6863168ac64c1b3e86e2e912dc1d692e60c0349d9c8109afbe9dc594e612e8a4f3f0cd00ab68b7dbfedf1812dd608570
7
+ data.tar.gz: 67fd627aabe9d7ccb53aec0d5c161d6ce255d51427166e0dfd3370210e1bb08bb242ec4d8632a73bcce006e13288057077e20b148b72092f60720ecd54d00291
data/CHANGELOG.md CHANGED
@@ -1,6 +1,15 @@
1
1
  Unreleased Changes
2
2
  ------------------
3
3
 
4
+ 3.121.2 (2021-10-18)
5
+ ------------------
6
+
7
+ * Issue - Fix an issue where Rest JSON services do not have a `Content-Type` header.
8
+
9
+ * Issue - Remove blank `Content-Type` header from Net::HTTP handler, and prevent a default from being set.
10
+
11
+ * Issue - Set `Content-Length` only for HTTP methods that take a body.
12
+
4
13
  3.121.1 (2021-09-24)
5
14
  ------------------
6
15
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 3.121.1
1
+ 3.121.2
@@ -4,9 +4,26 @@ module Aws
4
4
  module Plugins
5
5
  module Protocols
6
6
  class ApiGateway < Seahorse::Client::Plugin
7
+
8
+ class ContentTypeHandler < Seahorse::Client::Handler
9
+ def call(context)
10
+ body = context.http_request.body
11
+ # Rest::Handler will set a default JSON body, so size can be checked
12
+ # if this handler is run after serialization.
13
+ if !body.respond_to?(:size) ||
14
+ (body.respond_to?(:size) && body.size > 0)
15
+ context.http_request.headers['Content-Type'] ||=
16
+ 'application/json'
17
+ end
18
+ @handler.call(context)
19
+ end
20
+ end
21
+
7
22
  handler(Rest::Handler)
23
+ handler(ContentTypeHandler, priority: 30)
8
24
  handler(Json::ErrorHandler, step: :sign)
9
25
  end
26
+
10
27
  end
11
28
  end
12
29
  end
@@ -5,10 +5,25 @@ module Aws
5
5
  module Protocols
6
6
  class RestJson < Seahorse::Client::Plugin
7
7
 
8
+ class ContentTypeHandler < Seahorse::Client::Handler
9
+ def call(context)
10
+ body = context.http_request.body
11
+ # Rest::Handler will set a default JSON body, so size can be checked
12
+ # if this handler is run after serialization.
13
+ if !body.respond_to?(:size) ||
14
+ (body.respond_to?(:size) && body.size > 0)
15
+ context.http_request.headers['Content-Type'] ||=
16
+ 'application/json'
17
+ end
18
+ @handler.call(context)
19
+ end
20
+ end
21
+
8
22
  handler(Rest::Handler)
23
+ handler(ContentTypeHandler, priority: 30)
9
24
  handler(Json::ErrorHandler, step: :sign)
10
-
11
25
  end
26
+
12
27
  end
13
28
  end
14
29
  end
@@ -17,11 +17,29 @@ module Aws
17
17
  # @param [Seahorse::Client::Http::Request] http_req
18
18
  # @param [Hash] params
19
19
  def apply(http_req, params)
20
- http_req.body = build_body(params)
20
+ body = build_body(params)
21
+ # for rest-json, ensure we send at least an empty object
22
+ # don't send an empty object for streaming? case.
23
+ if body.nil? && @serializer_class == Json::Builder &&
24
+ modeled_body? && !streaming?
25
+ body = '{}'
26
+ end
27
+ http_req.body = body
21
28
  end
22
29
 
23
30
  private
24
31
 
32
+ # operation is modeled for body when it is modeled for a payload
33
+ # either with payload trait or normal members.
34
+ def modeled_body?
35
+ return true if @rules[:payload]
36
+ @rules.shape.members.each do |member|
37
+ _name, shape = member
38
+ return true if shape.location.nil?
39
+ end
40
+ false
41
+ end
42
+
25
43
  def build_body(params)
26
44
  if streaming?
27
45
  params[@rules[:payload]]
@@ -29,7 +29,6 @@ require 'aws-sdk-core/plugins/transfer_encoding.rb'
29
29
  require 'aws-sdk-core/plugins/http_checksum.rb'
30
30
  require 'aws-sdk-core/plugins/signature_v4.rb'
31
31
  require 'aws-sdk-core/plugins/protocols/rest_json.rb'
32
- require 'aws-sdk-sso/plugins/content_type.rb'
33
32
 
34
33
  Aws::Plugins::GlobalConfiguration.add_identifier(:sso)
35
34
 
@@ -76,7 +75,6 @@ module Aws::SSO
76
75
  add_plugin(Aws::Plugins::HttpChecksum)
77
76
  add_plugin(Aws::Plugins::SignatureV4)
78
77
  add_plugin(Aws::Plugins::Protocols::RestJson)
79
- add_plugin(Aws::SSO::Plugins::ContentType)
80
78
 
81
79
  # @overload initialize(options)
82
80
  # @param [Hash] options
@@ -523,7 +521,7 @@ module Aws::SSO
523
521
  params: params,
524
522
  config: config)
525
523
  context[:gem_name] = 'aws-sdk-core'
526
- context[:gem_version] = '3.121.1'
524
+ context[:gem_version] = '3.121.2'
527
525
  Seahorse::Client::Request.new(handlers, context)
528
526
  end
529
527
 
data/lib/aws-sdk-sso.rb CHANGED
@@ -50,6 +50,6 @@ require_relative 'aws-sdk-sso/customizations'
50
50
  # @!group service
51
51
  module Aws::SSO
52
52
 
53
- GEM_VERSION = '3.121.1'
53
+ GEM_VERSION = '3.121.2'
54
54
 
55
55
  end
@@ -2303,7 +2303,7 @@ module Aws::STS
2303
2303
  params: params,
2304
2304
  config: config)
2305
2305
  context[:gem_name] = 'aws-sdk-core'
2306
- context[:gem_version] = '3.121.1'
2306
+ context[:gem_version] = '3.121.2'
2307
2307
  Seahorse::Client::Request.new(handlers, context)
2308
2308
  end
2309
2309
 
data/lib/aws-sdk-sts.rb CHANGED
@@ -50,6 +50,6 @@ require_relative 'aws-sdk-sts/customizations'
50
50
  # @!group service
51
51
  module Aws::STS
52
52
 
53
- GEM_VERSION = '3.121.1'
53
+ GEM_VERSION = '3.121.2'
54
54
 
55
55
  end
@@ -74,8 +74,9 @@ module Seahorse
74
74
  # @return [void]
75
75
  def transmit(config, req, resp)
76
76
  session(config, req) do |http|
77
+ # Monkey patch default content-type set by Net::HTTP
78
+ Thread.current[:net_http_skip_default_content_type] = true
77
79
  http.request(build_net_request(req)) do |net_resp|
78
-
79
80
  status_code = net_resp.code.to_i
80
81
  headers = extract_headers(net_resp)
81
82
 
@@ -96,6 +97,9 @@ module Seahorse
96
97
  rescue => error
97
98
  # not retryable
98
99
  resp.signal_error(error)
100
+ ensure
101
+ # ensure we turn off monkey patch in case of error
102
+ Thread.current[:net_http_skip_default_content_type] = nil
99
103
  end
100
104
 
101
105
  def complete_response(req, resp, bytes_received)
@@ -147,7 +151,12 @@ module Seahorse
147
151
  def build_net_request(request)
148
152
  request_class = net_http_request_class(request)
149
153
  req = request_class.new(request.endpoint.request_uri, headers(request))
150
- req.body_stream = request.body
154
+ # Net::HTTP adds a default Content-Type when a body is present.
155
+ # Set the body stream when it has an unknown size or when it is > 0.
156
+ if !request.body.respond_to?(:size) ||
157
+ (request.body.respond_to?(:size) && request.body.size > 0)
158
+ req.body_stream = request.body
159
+ end
151
160
  req
152
161
  end
153
162
 
@@ -166,14 +175,13 @@ module Seahorse
166
175
  # @return [Hash] Returns a vanilla hash of headers to send with the
167
176
  # HTTP request.
168
177
  def headers(request)
169
- # Net::HTTP adds default headers for content-type to POSTs (1.8.7+)
170
- # and accept-encoding (2.0.0+). Setting a default empty value defeats
171
- # this.
178
+ # Net::HTTP adds a default header for accept-encoding (2.0.0+).
179
+ # Setting a default empty value defeats this.
172
180
  #
173
- # Removing these are necessary for most services to not break request
181
+ # Removing this is necessary for most services to not break request
174
182
  # signatures as well as dynamodb crc32 checks (these fail if the
175
183
  # response is gzipped).
176
- headers = { 'content-type' => '', 'accept-encoding' => '' }
184
+ headers = { 'accept-encoding' => '' }
177
185
  request.headers.each_pair do |key, value|
178
186
  headers[key] = value
179
187
  end
@@ -11,10 +11,26 @@ module Seahorse
11
11
  module Patches
12
12
 
13
13
  def self.apply!
14
+ Net::HTTPGenericRequest.prepend(PatchDefaultContentType)
14
15
  return unless RUBY_VERSION < '2.5'
16
+
15
17
  Net::HTTP::IDEMPOTENT_METHODS_.clear
16
18
  end
17
19
 
20
+ # For requests with bodys, Net::HTTP sets a default content type of:
21
+ # 'application/x-www-form-urlencoded'
22
+ # There are cases where we should not send content type at all.
23
+ # Even when no body is supplied, Net::HTTP uses a default empty body
24
+ # and sets it anyway. This patch disables the behavior when a Thread
25
+ # local variable is set.
26
+ module PatchDefaultContentType
27
+ def supply_default_content_type
28
+ return if Thread.current[:net_http_skip_default_content_type]
29
+
30
+ super
31
+ end
32
+ end
33
+
18
34
  end
19
35
  end
20
36
  end
@@ -7,16 +7,22 @@ module Seahorse
7
7
 
8
8
  # @api private
9
9
  class Handler < Client::Handler
10
+ # https://github.com/ruby/net-http/blob/master/lib/net/http/requests.rb
11
+ # Methods without body are forwards compatible, because content-length
12
+ # may be set for requests without body but is technically incorrect.
13
+ METHODS_WITHOUT_BODY = Set.new(
14
+ %w[GET HEAD DELETE OPTIONS TRACE COPY MOVE]
15
+ )
10
16
 
11
17
  def call(context)
12
- # If it's an IO object and not a File / String / String IO
13
- if context.http_request.body.respond_to?(:size)
14
- length = context.http_request.body.size
15
- context.http_request.headers['Content-Length'] = length
18
+ body = context.http_request.body
19
+ method = context.http_request.http_method
20
+ # We use Net::HTTP with body_stream which doesn't do this by default
21
+ if body.respond_to?(:size) && !METHODS_WITHOUT_BODY.include?(method)
22
+ context.http_request.headers['Content-Length'] = body.size
16
23
  end
17
24
  @handler.call(context)
18
25
  end
19
-
20
26
  end
21
27
 
22
28
  handler(Handler, step: :sign, priority: 0)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aws-sdk-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.121.1
4
+ version: 3.121.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Amazon Web Services
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-09-24 00:00:00.000000000 Z
11
+ date: 2021-10-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jmespath
@@ -230,7 +230,6 @@ files:
230
230
  - lib/aws-sdk-sso/client_api.rb
231
231
  - lib/aws-sdk-sso/customizations.rb
232
232
  - lib/aws-sdk-sso/errors.rb
233
- - lib/aws-sdk-sso/plugins/content_type.rb
234
233
  - lib/aws-sdk-sso/resource.rb
235
234
  - lib/aws-sdk-sso/types.rb
236
235
  - lib/aws-sdk-sts.rb
@@ -1,25 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Aws
4
- module SSO
5
- module Plugins
6
- class ContentType < Seahorse::Client::Plugin
7
-
8
- def add_handlers(handlers, config)
9
- handlers.add(Handler)
10
- end
11
-
12
- class Handler < Seahorse::Client::Handler
13
- def call(context)
14
- # Some operations break when given an empty content-type header.
15
- # The SDK adds this blank content-type header
16
- # since Net::HTTP provides a default that can break services.
17
- # We're setting one here even though it's not used or necessary.
18
- context.http_request.headers['content-type'] = 'application/json'
19
- @handler.call(context)
20
- end
21
- end
22
- end
23
- end
24
- end
25
- end