def client_request name, options, &read_block
return_or_raise(options) do
log_client_request(options) do
if config.stub_requests?
response = stub_for(name)
response.http_request = build_request(name, options)
response.request_options = options
response
else
client = self
response = new_response do
req = client.send(:build_request, name, options)
client.send(:sign_request, req)
req
end
response.request_type = name
response.request_options = options
if
cacheable_request?(name, options) and
cache = AWS.response_cache and
cached_response = cache.cached(response)
then
cached_response.cached = true
cached_response
else
options[:async] ?
make_async_request(response, &read_block) :
make_sync_request(response, &read_block)
response.on_success do
send("process_#{name}_response", response)
if cache = AWS.response_cache
cache.add(response)
end
end
response.on_complete do
if response.http_request.body_stream.is_a?(ManagedFile)
response.http_request.body_stream.close
end
end
response
end
end
end
end
end