feat: send x-goog-api-client header in all requests

This commit is contained in:
Daniel Azuma authored and GitHub committed 2019-08-16 10:13:11 -07:00
1 parent eea7d16b5e
commit 8cf4330494
3 files changed
+49 -1

No files matched your search

+12
View File
@@ -52,6 +52,7 @@ module Google
#
# @return [void]
def prepare!
set_xgac
if options && options.api_format_version
header['X-Goog-Api-Format-Version'] = options.api_format_version.to_s
end
@@ -125,6 +126,17 @@ module Google
private
def set_xgac
old_xgac = header
.find_all { |k, v| k.downcase == 'x-goog-api-client' }
.map { |(a, b)| b }
.join(' ')
xgac = "gl-ruby/#{RUBY_VERSION} gdcl/#{Google::Apis::VERSION}"
xgac = old_xgac.empty? ? xgac : "#{old_xgac} #{xgac}"
header.delete_if { |k, v| k.downcase == 'x-goog-api-client' }
header['X-Goog-Api-Client'] = xgac
end
# Attempt to parse a JSON error message
# @param [String] body
# HTTP response body