Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions google-apis-core/lib/google/apis/core/http_command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,9 @@ def prepare!
end

self.body = '' if self.body.nil? && [:post, :put, :patch].include?(method)
if defined?(::Google::Apis::Core::CompositeIO) && body.is_a?(::Google::Apis::Core::CompositeIO)
header["Content-Length"] ||= body.size.to_s
end
end

# Release any resources used by this command
Expand Down
5 changes: 4 additions & 1 deletion google-apis-core/spec/google/apis/core/batch_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,10 @@
--123abc--

EOF
expect(a_request(:post, 'https://www.googleapis.com/batch').with(body: expected_body)).to have_been_made
expect(
a_request(:post, 'https://www.googleapis.com/batch')
.with(body: expected_body, headers: {"Content-Length" => expected_body.size.to_s})
).to have_been_made
end

it 'should send content with authorization header when set' do
Expand Down
Loading