From ab06852ba2e7c6a4169f145d0b3c2b1b956bb2f5 Mon Sep 17 00:00:00 2001 From: Joseph Koshakow Date: Mon, 17 Mar 2025 12:55:06 -0400 Subject: [PATCH 1/2] 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. --- object_store/src/gcp/client.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/object_store/src/gcp/client.rs b/object_store/src/gcp/client.rs index 1cc72964f82c..25311a32c250 100644 --- a/object_store/src/gcp/client.rs +++ b/object_store/src/gcp/client.rs @@ -517,6 +517,7 @@ impl GoogleCloudStorageClient { // GCS doesn't allow empty multipart uploads let result = self .request(Method::PUT, path) + .header(&CONTENT_LENGTH, "0") .idempotent(true) .do_put() .await?; @@ -540,6 +541,7 @@ impl GoogleCloudStorageClient { let response = self .client .request(Method::POST, &url) + .header(&CONTENT_LENGTH, data.len()) .bearer_auth(&credential.bearer) .query(&[("uploadId", upload_id)]) .body(data) From 9db5923515cc628b40dc95f837db494414b8b29c Mon Sep 17 00:00:00 2001 From: Joseph Koshakow Date: Thu, 20 Mar 2025 17:29:46 -0400 Subject: [PATCH 2/2] Remove content length form multipart-complete --- object_store/src/gcp/client.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/object_store/src/gcp/client.rs b/object_store/src/gcp/client.rs index 25311a32c250..db4aa0a2d7d9 100644 --- a/object_store/src/gcp/client.rs +++ b/object_store/src/gcp/client.rs @@ -541,7 +541,6 @@ impl GoogleCloudStorageClient { let response = self .client .request(Method::POST, &url) - .header(&CONTENT_LENGTH, data.len()) .bearer_auth(&credential.bearer) .query(&[("uploadId", upload_id)]) .body(data)