diff --git a/lib/google/apis/core/http_command.rb b/lib/google/apis/core/http_command.rb index 0108a0b5d..d18eb85f2 100644 --- a/lib/google/apis/core/http_command.rb +++ b/lib/google/apis/core/http_command.rb @@ -264,7 +264,9 @@ module Google # Temporary workaround for Hurley bug where the connection preference # is ignored and it uses nested anyway req.url.query_class = Hurley::Query::Flat - query.each { | k, v| req.url.query[k] = v } + query.each do | k, v| + req.url.query[k] = normalize_query_value(v) + end # End workaround apply_request_options(req) end @@ -291,6 +293,19 @@ module Google req.header.update(header) req.options.timeout = options.timeout_sec end + + private + + def normalize_query_value(v) + case v + when Array + v.map { |v2| normalize_query_value(v2) } + when nil + nil + else + v.to_s + end + end end end end diff --git a/spec/google/apis/core/http_command_spec.rb b/spec/google/apis/core/http_command_spec.rb index 8543e7175..b3695b26b 100644 --- a/spec/google/apis/core/http_command_spec.rb +++ b/spec/google/apis/core/http_command_spec.rb @@ -272,4 +272,13 @@ RSpec.describe Google::Apis::Core::HttpCommand do command.query['a'] = [1,2,3] command.execute(client) end + + it 'should send falsey query parameters' do + stub_request(:get, 'https://www.googleapis.com/zoo/animals?a=0&b=false') + .to_return(status: [200, '']) + command = Google::Apis::Core::HttpCommand.new(:get, 'https://www.googleapis.com/zoo/animals') + command.query['a'] = 0 + command.query['b'] = false + command.execute(client) + end end