aws-sdk-s3 1.210.0 → 1.210.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 +5 -0
- data/VERSION +1 -1
- data/lib/aws-sdk-s3/client.rb +1 -1
- data/lib/aws-sdk-s3/plugins/http_200_errors.rb +58 -34
- data/lib/aws-sdk-s3.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 0e35a4e9d931cc6326d6e11fe2e73d571a4ca8cf0b24060ec73793144dfd9e8c
|
|
4
|
+
data.tar.gz: 5b80f94ff3edaf8de3728282dd2220cbadfe3eb58c2c29bb0f4f0730f0c4a7a5
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6107bf342199aee13b8a9b1fc13562c955a2efce427b8c57d34ed1fc98e7dc22ec16e2fc7e0480531141ff1e413f17fb63ec419f1068516624598758d783fb38
|
|
7
|
+
data.tar.gz: 0f2c903871fc55b830ee17ff090d831142d9d699220d93eae6005eedf2edb2a86519471803753af2e036e29795fdb928cf18271fddf229079940f4345a630106
|
data/CHANGELOG.md
CHANGED
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
1.210.
|
|
1
|
+
1.210.1
|
data/lib/aws-sdk-s3/client.rb
CHANGED
|
@@ -22283,7 +22283,7 @@ module Aws::S3
|
|
|
22283
22283
|
tracer: tracer
|
|
22284
22284
|
)
|
|
22285
22285
|
context[:gem_name] = 'aws-sdk-s3'
|
|
22286
|
-
context[:gem_version] = '1.210.
|
|
22286
|
+
context[:gem_version] = '1.210.1'
|
|
22287
22287
|
Seahorse::Client::Request.new(handlers, context)
|
|
22288
22288
|
end
|
|
22289
22289
|
|
|
@@ -3,15 +3,28 @@
|
|
|
3
3
|
module Aws
|
|
4
4
|
module S3
|
|
5
5
|
module Plugins
|
|
6
|
-
|
|
7
6
|
# A handful of Amazon S3 operations will respond with a 200 status
|
|
8
7
|
# code but will send an error in the response body. This plugin
|
|
9
8
|
# injects a handler that will parse 200 response bodies for potential
|
|
10
9
|
# errors, allowing them to be retried.
|
|
11
10
|
# @api private
|
|
12
11
|
class Http200Errors < Seahorse::Client::Plugin
|
|
13
|
-
|
|
14
12
|
class Handler < Seahorse::Client::Handler
|
|
13
|
+
# A regular expression to match error codes in the response body
|
|
14
|
+
CODE_PATTERN = %r{<Code>(.+?)</Code>}.freeze
|
|
15
|
+
private_constant :CODE_PATTERN
|
|
16
|
+
|
|
17
|
+
# A list of encodings we force into UTF-8
|
|
18
|
+
ENCODINGS_TO_FIX = [Encoding::US_ASCII, Encoding::ASCII_8BIT].freeze
|
|
19
|
+
private_constant :ENCODINGS_TO_FIX
|
|
20
|
+
|
|
21
|
+
# A regular expression to match detect errors in the response body
|
|
22
|
+
ERROR_PATTERN = /<\?xml\s[^>]*\?>\s*<Error>/.freeze
|
|
23
|
+
private_constant :ERROR_PATTERN
|
|
24
|
+
|
|
25
|
+
# A regular expression to match an error message in the response body
|
|
26
|
+
MESSAGE_PATTERN = %r{<Message>(.+?)</Message>}.freeze
|
|
27
|
+
private_constant :MESSAGE_PATTERN
|
|
15
28
|
|
|
16
29
|
def call(context)
|
|
17
30
|
@handler.call(context).on(200) do |response|
|
|
@@ -28,29 +41,37 @@ module Aws
|
|
|
28
41
|
|
|
29
42
|
private
|
|
30
43
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
44
|
+
def build_error(context, code, message)
|
|
45
|
+
S3::Errors.error_class(code).new(context, message)
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def check_for_error(context)
|
|
49
|
+
xml = normalize_encoding(context.http_response.body_contents)
|
|
50
|
+
|
|
51
|
+
if xml.match?(ERROR_PATTERN)
|
|
52
|
+
error_code = xml.match(CODE_PATTERN)[1]
|
|
53
|
+
error_message = xml.match(MESSAGE_PATTERN)[1]
|
|
54
|
+
build_error(context, error_code, error_message)
|
|
55
|
+
elsif incomplete_xml_body?(xml, context.operation.output)
|
|
56
|
+
Seahorse::Client::NetworkingError.new(
|
|
57
|
+
build_error(context, 'InternalError', 'Empty or incomplete response body')
|
|
58
|
+
)
|
|
39
59
|
end
|
|
40
60
|
end
|
|
41
61
|
|
|
62
|
+
# Must have a member in the body and have the start of an XML Tag.
|
|
63
|
+
# Other incomplete xml bodies will result in an XML ParsingError.
|
|
64
|
+
def incomplete_xml_body?(xml, output)
|
|
65
|
+
members_in_body?(output) && !xml.match(/<\w/)
|
|
66
|
+
end
|
|
67
|
+
|
|
42
68
|
# Checks if the output shape is a structure shape and has members that
|
|
43
69
|
# are in the body for the case of a payload and a normal structure. A
|
|
44
70
|
# non-structure shape will not have members in the body. In the case
|
|
45
71
|
# of a string or blob, the body contents would have been checked first
|
|
46
72
|
# before this method is called in incomplete_xml_body?.
|
|
47
73
|
def members_in_body?(output)
|
|
48
|
-
shape =
|
|
49
|
-
if output[:payload_member]
|
|
50
|
-
output[:payload_member].shape
|
|
51
|
-
else
|
|
52
|
-
output.shape
|
|
53
|
-
end
|
|
74
|
+
shape = resolve_shape(output)
|
|
54
75
|
|
|
55
76
|
if structure_shape?(shape)
|
|
56
77
|
shape.members.any? { |_, k| k.location.nil? }
|
|
@@ -59,30 +80,33 @@ module Aws
|
|
|
59
80
|
end
|
|
60
81
|
end
|
|
61
82
|
|
|
62
|
-
|
|
63
|
-
|
|
83
|
+
# Fixes encoding issues when S3 returns UTF-8 content with missing charset in Content-Type header or omits
|
|
84
|
+
# Content-Type header entirely. Net::HTTP defaults to US-ASCII or ASCII-8BIT when charset is unspecified.
|
|
85
|
+
def normalize_encoding(xml)
|
|
86
|
+
return xml unless xml.is_a?(String) && ENCODINGS_TO_FIX.include?(xml.encoding)
|
|
87
|
+
|
|
88
|
+
xml.force_encoding('UTF-8')
|
|
64
89
|
end
|
|
65
90
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
91
|
+
def resolve_shape(output)
|
|
92
|
+
return output.shape unless output[:payload_member]
|
|
93
|
+
|
|
94
|
+
output[:payload_member].shape
|
|
70
95
|
end
|
|
71
96
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
if
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
Seahorse::Client::NetworkingError.new(
|
|
80
|
-
S3::Errors
|
|
81
|
-
.error_class('InternalError')
|
|
82
|
-
.new(context, 'Empty or incomplete response body')
|
|
83
|
-
)
|
|
97
|
+
# Streaming outputs are not subject to 200 errors.
|
|
98
|
+
def streaming_output?(output)
|
|
99
|
+
if (payload = output[:payload_member])
|
|
100
|
+
# checking ref and shape
|
|
101
|
+
payload['streaming'] || payload.shape['streaming'] || payload.eventstream
|
|
102
|
+
else
|
|
103
|
+
false
|
|
84
104
|
end
|
|
85
105
|
end
|
|
106
|
+
|
|
107
|
+
def structure_shape?(shape)
|
|
108
|
+
shape.is_a?(Seahorse::Model::Shapes::StructureShape)
|
|
109
|
+
end
|
|
86
110
|
end
|
|
87
111
|
|
|
88
112
|
handler(Handler, step: :sign)
|
data/lib/aws-sdk-s3.rb
CHANGED