From 489378db5852d5e26a98295ab5fb8abe9653d710 Mon Sep 17 00:00:00 2001 From: Steve Bazyl Date: Fri, 31 Mar 2017 14:59:07 -0700 Subject: [PATCH] Ensure content length when empty body, hook up httpclient to logger when debugging --- lib/google/apis/core/base_service.rb | 4 ++++ lib/google/apis/core/http_command.rb | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/lib/google/apis/core/base_service.rb b/lib/google/apis/core/base_service.rb index da9dccacd..81799bced 100644 --- a/lib/google/apis/core/base_service.rb +++ b/lib/google/apis/core/base_service.rb @@ -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 diff --git a/lib/google/apis/core/http_command.rb b/lib/google/apis/core/http_command.rb index 9eb123468..aff138317 100644 --- a/lib/google/apis/core/http_command.rb +++ b/lib/google/apis/core/http_command.rb @@ -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