Skip to content

Commit

Permalink
add content length
Browse files Browse the repository at this point in the history
  • Loading branch information
wcy-fdu committed Feb 17, 2024
1 parent 7e17021 commit 53dd3bb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
21 changes: 9 additions & 12 deletions core/src/services/azblob/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)?;

Expand All @@ -438,6 +432,7 @@ impl AzblobCore {
&self,
path: &str,
block_ids: Vec<Uuid>,
args: &OpWrite,
) -> Result<Request<AsyncBody>> {
let p = build_abs_path(&self.root, path);
let url = format!(
Expand All @@ -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
Expand All @@ -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)?;
Expand All @@ -480,9 +476,10 @@ impl AzblobCore {
&self,
path: &str,
block_ids: Vec<Uuid>,
args: &OpWrite,
) -> Result<Response<IncomingAsyncBody>> {
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?;
Expand Down
2 changes: 1 addition & 1 deletion core/src/services/azblob/writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ impl oio::BlockWrite for AzblobWriter {
async fn complete_block(&self, block_ids: Vec<Uuid>) -> 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();
Expand Down

0 comments on commit 53dd3bb

Please sign in to comment.