You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@opendal.apache.org by xu...@apache.org on 2024/03/14 13:22:37 UTC

(opendal) 05/07: Cleanup async body

This is an automated email from the ASF dual-hosted git repository.

xuanwo pushed a commit to branch cleanup
in repository https://gitbox.apache.org/repos/asf/opendal.git

commit 8c0e91e189723743b36cace50a65eedd1fe2d7ec
Author: Xuanwo <gi...@xuanwo.io>
AuthorDate: Thu Mar 14 21:18:35 2024 +0800

    Cleanup async body
    
    Signed-off-by: Xuanwo <gi...@xuanwo.io>
---
 core/src/raw/http_util/body.rs        |  4 ----
 core/src/raw/http_util/client.rs      | 11 -----------
 core/src/raw/http_util/multipart.rs   |  1 -
 core/src/raw/oio/write/block_write.rs |  2 --
 core/src/services/gcs/core.rs         |  3 ---
 5 files changed, 21 deletions(-)

diff --git a/core/src/raw/http_util/body.rs b/core/src/raw/http_util/body.rs
index 4c39dfa74e..e32dcb46d4 100644
--- a/core/src/raw/http_util/body.rs
+++ b/core/src/raw/http_util/body.rs
@@ -35,10 +35,6 @@ pub enum AsyncBody {
     Empty,
     /// Body with bytes.
     Bytes(Bytes),
-    /// Body with chunked bytes.
-    ///
-    /// This is nearly the same with stream, but we can save an extra box.
-    ChunkedBytes(oio::ChunkedBytes),
     /// Body with stream.
     Stream(oio::Streamer),
 }
diff --git a/core/src/raw/http_util/client.rs b/core/src/raw/http_util/client.rs
index 2c5e4bc5c7..e8108e3a6a 100644
--- a/core/src/raw/http_util/client.rs
+++ b/core/src/raw/http_util/client.rs
@@ -118,17 +118,6 @@ impl HttpClient {
         req_builder = match body {
             AsyncBody::Empty => req_builder.body(reqwest::Body::from("")),
             AsyncBody::Bytes(bs) => req_builder.body(reqwest::Body::from(bs)),
-            AsyncBody::ChunkedBytes(bs) => {
-                #[cfg(not(target_arch = "wasm32"))]
-                {
-                    req_builder.body(reqwest::Body::wrap_stream(bs))
-                }
-                #[cfg(target_arch = "wasm32")]
-                {
-                    let bs = oio::WriteBuf::bytes(&bs, bs.len());
-                    req_builder.body(reqwest::Body::from(bs))
-                }
-            }
             AsyncBody::Stream(s) => {
                 #[cfg(not(target_arch = "wasm32"))]
                 {
diff --git a/core/src/raw/http_util/multipart.rs b/core/src/raw/http_util/multipart.rs
index 81e6db7147..4d40b01a61 100644
--- a/core/src/raw/http_util/multipart.rs
+++ b/core/src/raw/http_util/multipart.rs
@@ -404,7 +404,6 @@ impl MixedPart {
                 bs.len() as u64,
                 Some(Box::new(oio::Cursor::from(bs)) as Streamer),
             ),
-            AsyncBody::ChunkedBytes(bs) => (bs.len() as u64, Some(Box::new(bs) as Streamer)),
             AsyncBody::Stream(stream) => {
                 let len = parts
                     .headers
diff --git a/core/src/raw/oio/write/block_write.rs b/core/src/raw/oio/write/block_write.rs
index 28e6d88ed9..3b0266ffbd 100644
--- a/core/src/raw/oio/write/block_write.rs
+++ b/core/src/raw/oio/write/block_write.rs
@@ -287,7 +287,6 @@ mod tests {
     use super::*;
     use crate::raw::oio::StreamExt;
     use crate::raw::oio::Write;
-    use crate::raw::oio::WriteBuf;
 
     struct TestWrite {
         length: u64,
@@ -321,7 +320,6 @@ mod tests {
             let bs = match body {
                 AsyncBody::Empty => Bytes::new(),
                 AsyncBody::Bytes(bs) => bs,
-                AsyncBody::ChunkedBytes(cb) => cb.bytes(cb.remaining()),
                 AsyncBody::Stream(s) => s.collect().await.unwrap(),
             };
 
diff --git a/core/src/services/gcs/core.rs b/core/src/services/gcs/core.rs
index df112e504b..46cc2c4123 100644
--- a/core/src/services/gcs/core.rs
+++ b/core/src/services/gcs/core.rs
@@ -288,9 +288,6 @@ impl GcsCore {
                 AsyncBody::Bytes(bytes) => {
                     media_part = media_part.content(bytes);
                 }
-                AsyncBody::ChunkedBytes(bs) => {
-                    media_part = media_part.stream(bs.len() as u64, Box::new(bs));
-                }
                 AsyncBody::Stream(stream) => {
                     media_part = media_part.stream(size.unwrap(), stream);
                 }