Skip to content

Commit ab06852

Browse files
committed
Add content length to GCP multipart complete
This commit fixes the GCP mulipart complete implementation by adding the Content-Length header to XML requests. According to the docs, https://cloud.google.com/storage/docs/xml-api/post-object-complete, this header is required in the complete POST request, but wasn't being set previously. It seems like GCP doesn't actually validate this header, but it's better to set it in case they validate in the future. Additionally, GCP is strict about setting the Content-Length header on requests with empty bodies, so we also update an empty PUT request, https://cloud.google.com/storage/docs/xml-api/put-object-multipart, with the header.
1 parent 9d9674b commit ab06852

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

object_store/src/gcp/client.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -517,6 +517,7 @@ impl GoogleCloudStorageClient {
517517
// GCS doesn't allow empty multipart uploads
518518
let result = self
519519
.request(Method::PUT, path)
520+
.header(&CONTENT_LENGTH, "0")
520521
.idempotent(true)
521522
.do_put()
522523
.await?;
@@ -540,6 +541,7 @@ impl GoogleCloudStorageClient {
540541
let response = self
541542
.client
542543
.request(Method::POST, &url)
544+
.header(&CONTENT_LENGTH, data.len())
543545
.bearer_auth(&credential.bearer)
544546
.query(&[("uploadId", upload_id)])
545547
.body(data)

0 commit comments

Comments
 (0)