From 53dd3bbf3f8cb79d196012c38f507a4970a6c6b1 Mon Sep 17 00:00:00 2001 From: congyi <15605187270@163.com> Date: Sat, 17 Feb 2024 17:08:03 +0800 Subject: [PATCH] add content length --- core/src/services/azblob/core.rs | 21 +++++++++------------ core/src/services/azblob/writer.rs | 2 +- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/core/src/services/azblob/core.rs b/core/src/services/azblob/core.rs index 2c1e67030997..91554fe1d355 100644 --- a/core/src/services/azblob/core.rs +++ b/core/src/services/azblob/core.rs @@ -408,12 +408,6 @@ impl AzblobCore { if let Some(ty) = args.content_type() { req = req.header(CONTENT_TYPE, ty) } - - req = req.header( - HeaderName::from_static(constants::X_MS_BLOB_TYPE), - "BlockBlob", - ); - // Set body let req = req.body(body).map_err(new_request_build_error)?; @@ -438,6 +432,7 @@ impl AzblobCore { &self, path: &str, block_ids: Vec, + args: &OpWrite, ) -> Result> { let p = build_abs_path(&self.root, path); let url = format!( @@ -451,11 +446,9 @@ impl AzblobCore { // Set SSE headers. let mut req = self.insert_sse_headers(req); - - req = req.header( - HeaderName::from_static(constants::X_MS_BLOB_TYPE), - "BlockBlob", - ); + if let Some(cache_control) = args.cache_control() { + req = req.header(constants::X_MS_BLOB_CACHE_CONTROL, cache_control); + } let content = quick_xml::se::to_string(&PutBlockListRequest { latest: block_ids @@ -469,6 +462,9 @@ impl AzblobCore { .collect(), }) .map_err(new_xml_deserialize_error)?; + + req = req.header(CONTENT_LENGTH, content.len()); + let req = req .body(AsyncBody::Bytes(Bytes::from(content))) .map_err(new_request_build_error)?; @@ -480,9 +476,10 @@ impl AzblobCore { &self, path: &str, block_ids: Vec, + args: &OpWrite, ) -> Result> { let mut req = self - .azblob_complete_put_block_list_request(path, block_ids) + .azblob_complete_put_block_list_request(path, block_ids, args) .await?; self.sign(&mut req).await?; diff --git a/core/src/services/azblob/writer.rs b/core/src/services/azblob/writer.rs index f0d4dda8ab8e..e0cbc72f9aed 100644 --- a/core/src/services/azblob/writer.rs +++ b/core/src/services/azblob/writer.rs @@ -153,7 +153,7 @@ impl oio::BlockWrite for AzblobWriter { async fn complete_block(&self, block_ids: Vec) -> Result<()> { let resp = self .core - .azblob_complete_put_block_list(&self.path, block_ids) + .azblob_complete_put_block_list(&self.path, block_ids, &self.op) .await?; let status = resp.status();