aws-sdk-core 3.46.0 → 3.94.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/VERSION +1 -1
- data/lib/aws-sdk-core.rb +7 -0
- data/lib/aws-sdk-core/arn.rb +77 -0
- data/lib/aws-sdk-core/arn_parser.rb +38 -0
- data/lib/aws-sdk-core/assume_role_web_identity_credentials.rb +102 -0
- data/lib/aws-sdk-core/async_client_stubs.rb +80 -0
- data/lib/aws-sdk-core/binary.rb +3 -0
- data/lib/aws-sdk-core/binary/decode_handler.rb +9 -1
- data/lib/aws-sdk-core/binary/encode_handler.rb +32 -0
- data/lib/aws-sdk-core/binary/event_builder.rb +122 -0
- data/lib/aws-sdk-core/binary/event_parser.rb +48 -18
- data/lib/aws-sdk-core/binary/event_stream_decoder.rb +5 -2
- data/lib/aws-sdk-core/binary/event_stream_encoder.rb +53 -0
- data/lib/aws-sdk-core/client_side_monitoring/publisher.rb +9 -1
- data/lib/aws-sdk-core/client_stubs.rb +10 -9
- data/lib/aws-sdk-core/credential_provider.rb +0 -31
- data/lib/aws-sdk-core/credential_provider_chain.rb +79 -39
- data/lib/aws-sdk-core/deprecations.rb +16 -10
- data/lib/aws-sdk-core/ecs_credentials.rb +12 -8
- data/lib/aws-sdk-core/endpoint_cache.rb +14 -11
- data/lib/aws-sdk-core/errors.rb +94 -6
- data/lib/aws-sdk-core/event_emitter.rb +42 -0
- data/lib/aws-sdk-core/instance_profile_credentials.rb +120 -38
- data/lib/aws-sdk-core/json.rb +13 -14
- data/lib/aws-sdk-core/json/error_handler.rb +19 -2
- data/lib/aws-sdk-core/json/handler.rb +19 -1
- data/lib/aws-sdk-core/log/formatter.rb +7 -1
- data/lib/aws-sdk-core/log/param_filter.rb +3 -3
- data/lib/aws-sdk-core/pageable_response.rb +34 -20
- data/lib/aws-sdk-core/param_validator.rb +11 -5
- data/lib/aws-sdk-core/plugins/client_metrics_plugin.rb +26 -1
- data/lib/aws-sdk-core/plugins/endpoint_discovery.rb +1 -1
- data/lib/aws-sdk-core/plugins/event_stream_configuration.rb +14 -0
- data/lib/aws-sdk-core/plugins/invocation_id.rb +33 -0
- data/lib/aws-sdk-core/plugins/regional_endpoint.rb +8 -1
- data/lib/aws-sdk-core/plugins/retries/client_rate_limiter.rb +137 -0
- data/lib/aws-sdk-core/plugins/retries/clock_skew.rb +98 -0
- data/lib/aws-sdk-core/plugins/retries/error_inspector.rb +142 -0
- data/lib/aws-sdk-core/plugins/retries/retry_quota.rb +57 -0
- data/lib/aws-sdk-core/plugins/retry_errors.rb +290 -106
- data/lib/aws-sdk-core/plugins/signature_v4.rb +13 -2
- data/lib/aws-sdk-core/plugins/stub_responses.rb +20 -7
- data/lib/aws-sdk-core/plugins/transfer_encoding.rb +51 -0
- data/lib/aws-sdk-core/plugins/user_agent.rb +4 -8
- data/lib/aws-sdk-core/process_credentials.rb +9 -3
- data/lib/aws-sdk-core/shared_config.rb +95 -125
- data/lib/aws-sdk-core/structure.rb +1 -2
- data/lib/aws-sdk-core/stubbing/protocols/rest.rb +19 -0
- data/lib/aws-sdk-core/stubbing/stub_data.rb +13 -4
- data/lib/aws-sdk-core/util.rb +4 -0
- data/lib/aws-sdk-core/waiters/waiter.rb +2 -2
- data/lib/aws-sdk-core/xml/error_handler.rb +26 -3
- data/lib/aws-sdk-sts.rb +7 -4
- data/lib/aws-sdk-sts/client.rb +1109 -459
- data/lib/aws-sdk-sts/client_api.rb +67 -0
- data/lib/aws-sdk-sts/customizations.rb +2 -0
- data/lib/aws-sdk-sts/errors.rb +150 -0
- data/lib/aws-sdk-sts/plugins/sts_regional_endpoints.rb +32 -0
- data/lib/aws-sdk-sts/presigner.rb +67 -0
- data/lib/aws-sdk-sts/resource.rb +1 -0
- data/lib/aws-sdk-sts/types.rb +736 -176
- data/lib/seahorse.rb +9 -0
- data/lib/seahorse/client/async_base.rb +50 -0
- data/lib/seahorse/client/async_response.rb +62 -0
- data/lib/seahorse/client/base.rb +4 -2
- data/lib/seahorse/client/configuration.rb +4 -2
- data/lib/seahorse/client/events.rb +1 -1
- data/lib/seahorse/client/h2/connection.rb +246 -0
- data/lib/seahorse/client/h2/handler.rb +151 -0
- data/lib/seahorse/client/handler_list_entry.rb +2 -2
- data/lib/seahorse/client/http/async_response.rb +42 -0
- data/lib/seahorse/client/http/response.rb +13 -8
- data/lib/seahorse/client/logging/formatter.rb +4 -2
- data/lib/seahorse/client/net_http/connection_pool.rb +19 -20
- data/lib/seahorse/client/net_http/handler.rb +7 -1
- data/lib/seahorse/client/net_http/patches.rb +7 -1
- data/lib/seahorse/client/networking_error.rb +28 -0
- data/lib/seahorse/client/plugin.rb +5 -4
- data/lib/seahorse/client/plugins/content_length.rb +5 -2
- data/lib/seahorse/client/plugins/h2.rb +64 -0
- data/lib/seahorse/client/response.rb +3 -5
- data/lib/seahorse/model/api.rb +4 -0
- data/lib/seahorse/model/operation.rb +4 -0
- data/lib/seahorse/model/shapes.rb +2 -2
- metadata +43 -10
@@ -0,0 +1,151 @@
|
|
1
|
+
if RUBY_VERSION >= '2.1'
|
2
|
+
begin
|
3
|
+
require 'http/2'
|
4
|
+
rescue LoadError; end
|
5
|
+
end
|
6
|
+
require 'securerandom'
|
7
|
+
|
8
|
+
module Seahorse
|
9
|
+
module Client
|
10
|
+
# @api private
|
11
|
+
module H2
|
12
|
+
|
13
|
+
NETWORK_ERRORS = [
|
14
|
+
SocketError, EOFError, IOError, Timeout::Error,
|
15
|
+
Errno::ECONNABORTED, Errno::ECONNRESET, Errno::EPIPE,
|
16
|
+
Errno::EINVAL, Errno::ETIMEDOUT, OpenSSL::SSL::SSLError,
|
17
|
+
Errno::EHOSTUNREACH, Errno::ECONNREFUSED,# OpenSSL::SSL::SSLErrorWaitReadable
|
18
|
+
]
|
19
|
+
|
20
|
+
# @api private
|
21
|
+
DNS_ERROR_MESSAGES = [
|
22
|
+
'getaddrinfo: nodename nor servname provided, or not known', # MacOS
|
23
|
+
'getaddrinfo: Name or service not known' # GNU
|
24
|
+
]
|
25
|
+
|
26
|
+
class Handler < Client::Handler
|
27
|
+
|
28
|
+
def call(context)
|
29
|
+
stream = nil
|
30
|
+
begin
|
31
|
+
conn = context.client.connection
|
32
|
+
stream = conn.new_stream
|
33
|
+
|
34
|
+
stream_mutex = Mutex.new
|
35
|
+
close_condition = ConditionVariable.new
|
36
|
+
sync_queue = Queue.new
|
37
|
+
|
38
|
+
conn.connect(context.http_request.endpoint)
|
39
|
+
_register_callbacks(
|
40
|
+
context.http_response,
|
41
|
+
stream,
|
42
|
+
stream_mutex,
|
43
|
+
close_condition,
|
44
|
+
sync_queue
|
45
|
+
)
|
46
|
+
|
47
|
+
conn.debug_output("sending initial request ...")
|
48
|
+
if input_emitter = context[:input_event_emitter]
|
49
|
+
_send_initial_headers(context.http_request, stream)
|
50
|
+
|
51
|
+
# prepare for sending events later
|
52
|
+
input_emitter.stream = stream
|
53
|
+
# request sigv4 serves as the initial #prior_signature
|
54
|
+
input_emitter.encoder.prior_signature =
|
55
|
+
context.http_request.headers['authorization'].split('Signature=').last
|
56
|
+
input_emitter.validate_event = context.config.validate_params
|
57
|
+
else
|
58
|
+
_send_initial_headers(context.http_request, stream)
|
59
|
+
_send_initial_data(context.http_request, stream)
|
60
|
+
end
|
61
|
+
|
62
|
+
conn.start(stream)
|
63
|
+
rescue *NETWORK_ERRORS => error
|
64
|
+
error = NetworkingError.new(
|
65
|
+
error, error_message(context.http_request, error))
|
66
|
+
context.http_response.signal_error(error)
|
67
|
+
rescue => error
|
68
|
+
conn.debug_output(error.inspect)
|
69
|
+
# not retryable
|
70
|
+
context.http_response.signal_error(error)
|
71
|
+
end
|
72
|
+
|
73
|
+
AsyncResponse.new(
|
74
|
+
context: context,
|
75
|
+
stream: stream,
|
76
|
+
stream_mutex: stream_mutex,
|
77
|
+
close_condition: close_condition,
|
78
|
+
sync_queue: sync_queue
|
79
|
+
)
|
80
|
+
end
|
81
|
+
|
82
|
+
private
|
83
|
+
|
84
|
+
def _register_callbacks(resp, stream, stream_mutex, close_condition, sync_queue)
|
85
|
+
stream.on(:headers) do |headers|
|
86
|
+
resp.signal_headers(headers)
|
87
|
+
end
|
88
|
+
|
89
|
+
stream.on(:data) do |data|
|
90
|
+
resp.signal_data(data)
|
91
|
+
end
|
92
|
+
|
93
|
+
stream.on(:close) do
|
94
|
+
resp.signal_done
|
95
|
+
# block until #wait is ready for signal
|
96
|
+
# else deadlock may happen because #signal happened
|
97
|
+
# eariler than #wait (see AsyncResponse#wait)
|
98
|
+
sync_queue.pop
|
99
|
+
stream_mutex.synchronize {
|
100
|
+
close_condition.signal
|
101
|
+
}
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
def _send_initial_headers(req, stream)
|
106
|
+
begin
|
107
|
+
headers = _h2_headers(req)
|
108
|
+
stream.headers(headers, end_stream: false)
|
109
|
+
rescue => e
|
110
|
+
raise Http2InitialRequestError.new(e)
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
def _send_initial_data(req, stream)
|
115
|
+
begin
|
116
|
+
data = req.body.read
|
117
|
+
stream.data(data, end_stream: true)
|
118
|
+
rescue => e
|
119
|
+
raise Http2InitialRequestError.new(e)
|
120
|
+
end
|
121
|
+
data
|
122
|
+
end
|
123
|
+
|
124
|
+
# H2 pseudo headers
|
125
|
+
# https://http2.github.io/http2-spec/#rfc.section.8.1.2.3
|
126
|
+
def _h2_headers(req)
|
127
|
+
headers = {}
|
128
|
+
headers[':method'] = req.http_method.upcase
|
129
|
+
headers[':scheme'] = req.endpoint.scheme
|
130
|
+
headers[':path'] = req.endpoint.path.empty? ? '/' : req.endpoint.path
|
131
|
+
if req.endpoint.query && !req.endpoint.query.empty?
|
132
|
+
headers[':path'] += "?#{req.endpoint.query}"
|
133
|
+
end
|
134
|
+
req.headers.each {|k, v| headers[k.downcase] = v }
|
135
|
+
headers
|
136
|
+
end
|
137
|
+
|
138
|
+
def error_message(req, error)
|
139
|
+
if error.is_a?(SocketError) && DNS_ERROR_MESSAGES.include?(error.message)
|
140
|
+
host = req.endpoint.host
|
141
|
+
"unable to connect to `#{host}`; SocketError: #{error.message}"
|
142
|
+
else
|
143
|
+
error.message
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
end
|
148
|
+
|
149
|
+
end
|
150
|
+
end
|
151
|
+
end
|
@@ -77,8 +77,8 @@ module Seahorse
|
|
77
77
|
if options.key?(name)
|
78
78
|
options[name]
|
79
79
|
else
|
80
|
-
msg = "
|
81
|
-
raise ArgumentError, msg %
|
80
|
+
msg = "missing option: `%s'"
|
81
|
+
raise ArgumentError, msg % name.inspect
|
82
82
|
end
|
83
83
|
end
|
84
84
|
|
@@ -0,0 +1,42 @@
|
|
1
|
+
module Seahorse
|
2
|
+
module Client
|
3
|
+
module Http
|
4
|
+
class AsyncResponse < Seahorse::Client::Http::Response
|
5
|
+
|
6
|
+
def initialize(options = {})
|
7
|
+
super
|
8
|
+
end
|
9
|
+
|
10
|
+
def signal_headers(headers)
|
11
|
+
# H2 headers arrive as array of pair
|
12
|
+
hash = headers.inject({}) do |h, pair|
|
13
|
+
key, value = pair
|
14
|
+
h[key] = value
|
15
|
+
h
|
16
|
+
end
|
17
|
+
@status_code = hash[":status"].to_i
|
18
|
+
@headers = Headers.new(hash)
|
19
|
+
emit(:headers, @status_code, @headers)
|
20
|
+
end
|
21
|
+
|
22
|
+
def signal_done(options = {})
|
23
|
+
# H2 only has header and body
|
24
|
+
# ':status' header will be sent back
|
25
|
+
if options.keys.sort == [:body, :headers]
|
26
|
+
signal_headers(options[:headers])
|
27
|
+
signal_data(options[:body])
|
28
|
+
signal_done
|
29
|
+
elsif options.empty?
|
30
|
+
@body.rewind if @body.respond_to?(:rewind)
|
31
|
+
@done = true
|
32
|
+
emit(:done)
|
33
|
+
else
|
34
|
+
msg = "options must be empty or must contain :headers and :body"
|
35
|
+
raise ArgumentError, msg
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -40,12 +40,17 @@ module Seahorse
|
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
43
|
-
# @return [String]
|
43
|
+
# @return [String|Array]
|
44
44
|
def body_contents
|
45
|
-
body.
|
46
|
-
|
47
|
-
|
48
|
-
|
45
|
+
if body.is_a?(Array)
|
46
|
+
# an array of parsed events
|
47
|
+
body
|
48
|
+
else
|
49
|
+
body.rewind
|
50
|
+
contents = body.read
|
51
|
+
body.rewind
|
52
|
+
contents
|
53
|
+
end
|
49
54
|
end
|
50
55
|
|
51
56
|
# @param [Integer] status_code
|
@@ -117,15 +122,15 @@ module Seahorse
|
|
117
122
|
end
|
118
123
|
|
119
124
|
def on_headers(status_code_range = nil, &block)
|
120
|
-
@listeners[:headers] << listener(status_code_range,
|
125
|
+
@listeners[:headers] << listener(status_code_range, block)
|
121
126
|
end
|
122
127
|
|
123
128
|
def on_data(&callback)
|
124
|
-
@listeners[:data] <<
|
129
|
+
@listeners[:data] << callback
|
125
130
|
end
|
126
131
|
|
127
132
|
def on_done(status_code_range = nil, &callback)
|
128
|
-
listener = listener(status_code_range,
|
133
|
+
listener = listener(status_code_range, callback)
|
129
134
|
if @done
|
130
135
|
listener.call
|
131
136
|
else
|
@@ -173,9 +173,11 @@ module Seahorse
|
|
173
173
|
end
|
174
174
|
|
175
175
|
def _http_response_body(response)
|
176
|
-
response.context.http_response.body.respond_to?(:rewind)
|
177
|
-
summarize_value(response.context.http_response.body_contents)
|
176
|
+
if response.context.http_response.body.respond_to?(:rewind)
|
177
|
+
summarize_value(response.context.http_response.body_contents)
|
178
|
+
else
|
178
179
|
''
|
180
|
+
end
|
179
181
|
end
|
180
182
|
|
181
183
|
def _error_class(response)
|
@@ -18,6 +18,7 @@ module Seahorse
|
|
18
18
|
|
19
19
|
@pools_mutex = Mutex.new
|
20
20
|
@pools = {}
|
21
|
+
@default_logger = Logger.new($stdout)
|
21
22
|
|
22
23
|
OPTIONS = {
|
23
24
|
http_proxy: nil,
|
@@ -52,14 +53,14 @@ module Seahorse
|
|
52
53
|
|
53
54
|
# Makes an HTTP request, yielding a Net::HTTPResponse object.
|
54
55
|
#
|
55
|
-
# pool.request('http://domain', Net::HTTP::Get.new('/')) do |resp|
|
56
|
+
# pool.request(URI.parse('http://domain'), Net::HTTP::Get.new('/')) do |resp|
|
56
57
|
# puts resp.code # status code
|
57
58
|
# puts resp.to_h.inspect # dump the headers
|
58
59
|
# puts resp.body
|
59
60
|
# end
|
60
61
|
#
|
61
|
-
# @param [
|
62
|
-
# connect to (e.g. 'https://domain.com').
|
62
|
+
# @param [URI::HTTP, URI::HTTPS] endpoint The HTTP(S) endpoint
|
63
|
+
# to connect to (e.g. 'https://domain.com').
|
63
64
|
#
|
64
65
|
# @param [Net::HTTPRequest] request The request to make. This can be
|
65
66
|
# any request object from Net::HTTP (e.g. Net::HTTP::Get,
|
@@ -131,7 +132,7 @@ module Seahorse
|
|
131
132
|
nil
|
132
133
|
end
|
133
134
|
|
134
|
-
# Closes and removes
|
135
|
+
# Closes and removes all sessions from the pool.
|
135
136
|
# If empty! is called while there are outstanding requests they may
|
136
137
|
# get checked back into the pool, leaving the pool in a non-empty
|
137
138
|
# state.
|
@@ -165,16 +166,16 @@ module Seahorse
|
|
165
166
|
# requests through. Formatted like 'http://proxy.com:123'.
|
166
167
|
#
|
167
168
|
# @option options [Float] :http_open_timeout (15) The number of
|
168
|
-
# seconds to wait when opening
|
169
|
+
# seconds to wait when opening an HTTP session before raising a
|
169
170
|
# `Timeout::Error`.
|
170
171
|
#
|
171
172
|
# @option options [Integer] :http_read_timeout (60) The default
|
172
173
|
# number of seconds to wait for response data. This value can
|
173
174
|
# safely be set
|
174
|
-
# per-request on the session
|
175
|
+
# per-request on the session yielded by {#session_for}.
|
175
176
|
#
|
176
177
|
# @option options [Float] :http_idle_timeout (5) The number of
|
177
|
-
# seconds a connection is allowed to sit
|
178
|
+
# seconds a connection is allowed to sit idle before it is
|
178
179
|
# considered stale. Stale connections are closed and removed
|
179
180
|
# from the pool before making a request.
|
180
181
|
#
|
@@ -183,7 +184,7 @@ module Seahorse
|
|
183
184
|
# request body. This option has no effect unless the request has
|
184
185
|
# "Expect" header set to "100-continue". Defaults to `nil` which
|
185
186
|
# disables this behaviour. This value can safely be set per
|
186
|
-
# request on the session
|
187
|
+
# request on the session yielded by {#session_for}.
|
187
188
|
#
|
188
189
|
# @option options [Boolean] :http_wire_trace (false) When `true`,
|
189
190
|
# HTTP debug output will be sent to the `:logger`.
|
@@ -200,13 +201,13 @@ module Seahorse
|
|
200
201
|
# @option options [String] :ssl_ca_bundle Full path to the SSL
|
201
202
|
# certificate authority bundle file that should be used when
|
202
203
|
# verifying peer certificates. If you do not pass
|
203
|
-
# `:ssl_ca_bundle` or `:ssl_ca_directory` the
|
204
|
+
# `:ssl_ca_bundle` or `:ssl_ca_directory` the system default
|
204
205
|
# will be used if available.
|
205
206
|
#
|
206
207
|
# @option options [String] :ssl_ca_directory Full path of the
|
207
208
|
# directory that contains the unbundled SSL certificate
|
208
209
|
# authority files for verifying peer certificates. If you do
|
209
|
-
# not pass `:ssl_ca_bundle` or `:ssl_ca_directory` the
|
210
|
+
# not pass `:ssl_ca_bundle` or `:ssl_ca_directory` the
|
210
211
|
# system default will be used if available.
|
211
212
|
#
|
212
213
|
# @return [ConnectionPool]
|
@@ -217,7 +218,7 @@ module Seahorse
|
|
217
218
|
end
|
218
219
|
end
|
219
220
|
|
220
|
-
# @return [Array<ConnectionPool>] Returns a list of
|
221
|
+
# @return [Array<ConnectionPool>] Returns a list of the
|
221
222
|
# constructed connection pools.
|
222
223
|
def pools
|
223
224
|
@pools_mutex.synchronize do
|
@@ -231,7 +232,7 @@ module Seahorse
|
|
231
232
|
# @return [Hash]
|
232
233
|
def pool_options options
|
233
234
|
wire_trace = !!options[:http_wire_trace]
|
234
|
-
logger = options[:logger] ||
|
235
|
+
logger = options[:logger] || @default_logger if wire_trace
|
235
236
|
verify_peer = options.key?(:ssl_verify_peer) ?
|
236
237
|
!!options[:ssl_verify_peer] : true
|
237
238
|
{
|
@@ -279,6 +280,7 @@ module Seahorse
|
|
279
280
|
http = ExtendedSession.new(Net::HTTP.new(*args.compact))
|
280
281
|
http.set_debug_output(logger) if http_wire_trace?
|
281
282
|
http.open_timeout = http_open_timeout
|
283
|
+
http.keep_alive_timeout = http_idle_timeout if http.respond_to?(:keep_alive_timeout=)
|
282
284
|
|
283
285
|
if endpoint.scheme == 'https'
|
284
286
|
http.use_ssl = true
|
@@ -301,13 +303,10 @@ module Seahorse
|
|
301
303
|
# Removes stale sessions from the pool. This method *must* be called
|
302
304
|
# @note **Must** be called behind a `@pool_mutex` synchronize block.
|
303
305
|
def _clean
|
304
|
-
now =
|
306
|
+
now = Aws::Util.monotonic_milliseconds
|
305
307
|
@pool.each_pair do |endpoint,sessions|
|
306
308
|
sessions.delete_if do |session|
|
307
|
-
if
|
308
|
-
session.last_used.nil? or
|
309
|
-
now - session.last_used > http_idle_timeout
|
310
|
-
then
|
309
|
+
if session.last_used.nil? or now - session.last_used > http_idle_timeout * 1000
|
311
310
|
session.finish
|
312
311
|
true
|
313
312
|
end
|
@@ -315,7 +314,7 @@ module Seahorse
|
|
315
314
|
end
|
316
315
|
end
|
317
316
|
|
318
|
-
# Helper methods extended onto Net::HTTPSession objects
|
317
|
+
# Helper methods extended onto Net::HTTPSession objects opened by the
|
319
318
|
# connection pool.
|
320
319
|
# @api private
|
321
320
|
class ExtendedSession < Delegator
|
@@ -325,7 +324,7 @@ module Seahorse
|
|
325
324
|
@http = http
|
326
325
|
end
|
327
326
|
|
328
|
-
# @return [
|
327
|
+
# @return [Integer,nil]
|
329
328
|
attr_reader :last_used
|
330
329
|
|
331
330
|
def __getobj__
|
@@ -338,8 +337,8 @@ module Seahorse
|
|
338
337
|
|
339
338
|
# Sends the request and tracks that this session has been used.
|
340
339
|
def request(*args, &block)
|
341
|
-
@last_used = Time.now
|
342
340
|
@http.request(*args, &block)
|
341
|
+
@last_used = Aws::Util.monotonic_milliseconds
|
343
342
|
end
|
344
343
|
|
345
344
|
# Attempts to close/finish the session without raising an error.
|
@@ -163,7 +163,13 @@ module Seahorse
|
|
163
163
|
# @return [Hash] Returns a vanilla hash of headers to send with the
|
164
164
|
# HTTP request.
|
165
165
|
def headers(request)
|
166
|
-
#
|
166
|
+
# Net::HTTP adds default headers for content-type to POSTs (1.8.7+)
|
167
|
+
# and accept-encoding (2.0.0+). Setting a default empty value defeats
|
168
|
+
# this.
|
169
|
+
#
|
170
|
+
# Removing these are necessary for most services to not break request
|
171
|
+
# signatures as well as dynamodb crc32 checks (these fail if the
|
172
|
+
# response is gzipped).
|
167
173
|
headers = { 'content-type' => '', 'accept-encoding' => '' }
|
168
174
|
request.headers.each_pair do |key, value|
|
169
175
|
headers[key] = value
|
@@ -10,6 +10,12 @@ module Seahorse
|
|
10
10
|
|
11
11
|
def self.apply!
|
12
12
|
return unless RUBY_VERSION < '2.5'
|
13
|
+
if RUBY_VERSION >= '2.3'
|
14
|
+
Net::HTTP::IDEMPOTENT_METHODS_.clear
|
15
|
+
return
|
16
|
+
end
|
17
|
+
# no further patches needed for above versions
|
18
|
+
|
13
19
|
if RUBY_VERSION >= '2.0'
|
14
20
|
Net::HTTP.send(:include, Ruby_2)
|
15
21
|
Net::HTTP::IDEMPOTENT_METHODS_.clear
|
@@ -30,7 +36,7 @@ module Seahorse
|
|
30
36
|
begin
|
31
37
|
res = Net::HTTPResponse.read_new(@socket)
|
32
38
|
res.decode_content = req.decode_content
|
33
|
-
end while res.kind_of?(Net::
|
39
|
+
end while res.kind_of?(Net::HTTPInformation)
|
34
40
|
|
35
41
|
res.uri = req.uri
|
36
42
|
|
@@ -11,5 +11,33 @@ module Seahorse
|
|
11
11
|
attr_reader :original_error
|
12
12
|
|
13
13
|
end
|
14
|
+
|
15
|
+
# Raised when sending initial headers and data failed
|
16
|
+
# for event stream requests over Http2
|
17
|
+
class Http2InitialRequestError < StandardError
|
18
|
+
|
19
|
+
def initialize(error)
|
20
|
+
@original_error = error
|
21
|
+
end
|
22
|
+
|
23
|
+
# @return [HTTP2::Error]
|
24
|
+
attr_reader :original_error
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
|
+
# Raised when connection failed to initialize a new stream
|
29
|
+
class Http2StreamInitializeError < StandardError
|
30
|
+
|
31
|
+
def initialize(error)
|
32
|
+
@original_error = error
|
33
|
+
end
|
34
|
+
|
35
|
+
# @return [HTTP2::Error]
|
36
|
+
attr_reader :original_error
|
37
|
+
|
38
|
+
end
|
39
|
+
|
40
|
+
# Rasied when trying to use an closed connection
|
41
|
+
class Http2ConnectionClosedError < StandardError; end
|
14
42
|
end
|
15
43
|
end
|