From ef4c5c1f2f1e81821a1bd56b5d1cd1cbbf3af623 Mon Sep 17 00:00:00 2001 From: Steven Bazyl Date: Fri, 15 Feb 2013 13:13:58 -0800 Subject: [PATCH] Fix URI in batched request to allow query parameters --- lib/google/api_client/batch.rb | 2 +- spec/google/api_client/batch_spec.rb | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/google/api_client/batch.rb b/lib/google/api_client/batch.rb index 8dc8c4fcd..0a7e6b78c 100644 --- a/lib/google/api_client/batch.rb +++ b/lib/google/api_client/batch.rb @@ -286,7 +286,7 @@ module Google # the serialized request def serialize_call(call_id, call) method, uri, headers, body = call.to_http_request - request = "#{method.to_s.upcase} #{Addressable::URI.parse(uri).path} HTTP/1.1" + request = "#{method.to_s.upcase} #{Addressable::URI.parse(uri).request_uri} HTTP/1.1" headers.each do |header, value| request << "\r\n%s: %s" % [header, value] end diff --git a/spec/google/api_client/batch_spec.rb b/spec/google/api_client/batch_spec.rb index 1c28095ff..9573eea8e 100644 --- a/spec/google/api_client/batch_spec.rb +++ b/spec/google/api_client/batch_spec.rb @@ -33,6 +33,15 @@ describe Google::APIClient::BatchRequest do end).should raise_error(Google::APIClient::BatchError) end + it 'should allow query parameters in batch requests' do + batch = Google::APIClient::BatchRequest.new + batch.add(:uri => 'https://example.com', :parameters => { + 'a' => '12345' + }) + method, uri, headers, body = batch.to_http_request + body.read.should include("/?a=12345") + end + describe 'with the discovery API' do before do CLIENT.authorization = nil