#159 - Excute batch requests using the service's connection

This commit is contained in:
Steven Bazyl committed 2014-12-16 20:52:57 -08:00
1 parent 2622ebf8dc
commit d999033fd6
3 files changed
+40 -10

No files matched your search

+11 -8
View File
@@ -139,14 +139,17 @@ module Google
# the HTTP response.
def process_http_response(response)
content_type = find_header('Content-Type', response.headers)
boundary = /.*boundary=(.+)/.match(content_type)[1]
parts = response.body.split(/--#{Regexp.escape(boundary)}/)
parts = parts[1...-1]
parts.each do |part|
call_response = deserialize_call_response(part)
_, call, callback = @calls.assoc(call_response.call_id)
result = Google::APIClient::Result.new(call, call_response)
callback.call(result) if callback
m = /.*boundary=(.+)/.match(content_type)
if m
boundary = m[1]
parts = response.body.split(/--#{Regexp.escape(boundary)}/)
parts = parts[1...-1]
parts.each do |part|
call_response = deserialize_call_response(part)
_, call, callback = @calls.assoc(call_response.call_id)
result = Google::APIClient::Result.new(call, call_response)
callback.call(result) if callback
end
end
Google::APIClient::Result.new(self, response)
end
+1 -1
View File
@@ -225,7 +225,7 @@ module Google
result = @client.execute(params)
return Google::APIClient::Service::Result.new(request, result)
elsif request.instance_of? Google::APIClient::Service::BatchRequest
@client.execute(request.base_batch)
@client.execute(request.base_batch, {:connection => @connection})
end
end
end