Ensure content length when empty body, hook up httpclient to logger when debugging

This commit is contained in:
Steve Bazyl 2017-03-31 14:59:07 -07:00
parent aed2936248
commit 489378db58
2 changed files with 10 additions and 0 deletions

View File

@ -84,6 +84,8 @@ module Google
# Base service for all APIs. Not to be used directly.
#
class BaseService
include Logging
# Root URL (host/port) for the API
# @return [Addressable::URI]
attr_accessor :root_url
@ -393,6 +395,8 @@ module Google
end
client.follow_redirect_count = 5
client.default_header = { 'User-Agent' => user_agent }
client.debug_dev = logger if logger.level == Logger::DEBUG
client
end

View File

@ -155,6 +155,12 @@ module Google
else
@form_encoded = false
end
unless body
self.header['Content-Type'] = 'application/json'
self.header['Content-Length'] = 0
end
end
# Release any resources used by this command