Fix URI in batched request to allow query parameters

This commit is contained in:
Steven Bazyl 2013-02-15 13:13:58 -08:00
parent f421551018
commit ef4c5c1f2f
2 changed files with 10 additions and 1 deletions

View File

@ -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

View File

@ -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