Skip to content
Open
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: 2 additions & 1 deletion google-apis-core/lib/google/apis/core/storage_upload.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class StorageUploadCommand < ApiCommand
CONTENT_LENGTH_HEADER = "Content-Length"
CONTENT_TYPE_HEADER = "Content-Type"
UPLOAD_CONTENT_TYPE_HEADER = "X-Upload-Content-Type"
UPLOAD_CONTENT_LENGTH_HEADER = "X-Upload-Content-Length"
LOCATION_HEADER = "Location"
CONTENT_RANGE_HEADER = "Content-Range"
RESUMABLE = "resumable"
Expand Down Expand Up @@ -133,9 +134,9 @@ def initiate_resumable_upload(client)
request_query = query.dup
request_query['uploadType'] = RESUMABLE

request_header[CONTENT_LENGTH_HEADER] = upload_io.size.to_s
request_header[CONTENT_TYPE_HEADER] = JSON_CONTENT_TYPE
request_header[UPLOAD_CONTENT_TYPE_HEADER] = upload_content_type unless upload_content_type.nil?
request_header[UPLOAD_CONTENT_LENGTH_HEADER] = upload_io.size.to_s

response = client.post(url.to_s, body, request_header) do |request|
request.params.replace(request_query)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@
expect(a_request(:put, 'https://www.googleapis.com/zoo/animals')).to have_been_made
end

it 'should send X-Upload-Content-Length in initiate request' do
command.execute(client)
expect(a_request(:post, 'https://www.googleapis.com/zoo/animals?uploadType=resumable')
.with { |req| req.headers.key?('X-Upload-Content-Length') }).to have_been_made
end

it 'should generate a proper opencensus span' do
OpenCensus::Trace.start_request_trace do |span_context|
command.execute(client)
Expand Down
Loading