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

View File

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