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 2023/08/19 09:53:33 UTC
[incubator-opendal] 02/02: Fix test
This is an automated email from the ASF dual-hosted git repository.
xuanwo pushed a commit to branch remove-append
in repository https://gitbox.apache.org/repos/asf/incubator-opendal.git
commit c6dfaf5eb49486b25cf5f26a670bef5f18b6905c
Author: Xuanwo <gi...@xuanwo.io>
AuthorDate: Sat Aug 19 17:53:24 2023 +0800
Fix test
Signed-off-by: Xuanwo <gi...@xuanwo.io>
---
core/src/services/cos/writer.rs | 21 +++++++--------------
core/src/services/obs/writer.rs | 21 +++++++--------------
core/src/services/oss/writer.rs | 21 +++++++--------------
3 files changed, 21 insertions(+), 42 deletions(-)
diff --git a/core/src/services/cos/writer.rs b/core/src/services/cos/writer.rs
index ea62a663a..e64bc23a1 100644
--- a/core/src/services/cos/writer.rs
+++ b/core/src/services/cos/writer.rs
@@ -26,8 +26,6 @@ use super::error::parse_error;
use crate::raw::*;
use crate::*;
-pub const X_COS_NEXT_APPEND_POSITION: &str = "x-cos-next-append-position";
-
pub struct CosWriter {
core: Arc<CosCore>,
@@ -189,18 +187,13 @@ impl oio::AppendObjectWrite for CosWriter {
let status = resp.status();
match status {
StatusCode::OK => {
- let position = resp
- .headers()
- .get(X_COS_NEXT_APPEND_POSITION)
- .and_then(|v| v.to_str().ok())
- .and_then(|v| v.parse::<u64>().ok())
- .ok_or_else(|| {
- Error::new(
- ErrorKind::ConditionNotMatch,
- "missing x-cos-next-append-position, the object may not be appendable",
- )
- })?;
- Ok(position)
+ let content_length = parse_content_length(resp.headers())?.ok_or_else(|| {
+ Error::new(
+ ErrorKind::Unexpected,
+ "Content-Length not present in returning response",
+ )
+ })?;
+ Ok(content_length)
}
StatusCode::NOT_FOUND => Ok(0),
_ => Err(parse_error(resp).await?),
diff --git a/core/src/services/obs/writer.rs b/core/src/services/obs/writer.rs
index 4f079cf4c..efcfd3ab6 100644
--- a/core/src/services/obs/writer.rs
+++ b/core/src/services/obs/writer.rs
@@ -27,8 +27,6 @@ use crate::raw::oio::MultipartUploadPart;
use crate::raw::*;
use crate::*;
-pub const X_OBS_NEXT_APPEND_POSITION: &str = "x-obs-next-append-position";
-
pub struct ObsWriter {
core: Arc<ObsCore>,
@@ -179,18 +177,13 @@ impl oio::AppendObjectWrite for ObsWriter {
let status = resp.status();
match status {
StatusCode::OK => {
- let position = resp
- .headers()
- .get(X_OBS_NEXT_APPEND_POSITION)
- .and_then(|v| v.to_str().ok())
- .and_then(|v| v.parse::<u64>().ok())
- .ok_or_else(|| {
- Error::new(
- ErrorKind::Unexpected,
- "missing x-obs-next-append-position, the object may not be appendable",
- )
- })?;
- Ok(position)
+ let content_length = parse_content_length(resp.headers())?.ok_or_else(|| {
+ Error::new(
+ ErrorKind::Unexpected,
+ "Content-Length not present in returning response",
+ )
+ })?;
+ Ok(content_length)
}
StatusCode::NOT_FOUND => Ok(0),
_ => Err(parse_error(resp).await?),
diff --git a/core/src/services/oss/writer.rs b/core/src/services/oss/writer.rs
index cb0d25302..9faad249f 100644
--- a/core/src/services/oss/writer.rs
+++ b/core/src/services/oss/writer.rs
@@ -26,8 +26,6 @@ use super::error::parse_error;
use crate::raw::*;
use crate::*;
-pub const X_OSS_NEXT_APPEND_POSITION: &str = "x-oss-next-append-position";
-
pub struct OssWriter {
core: Arc<OssCore>,
@@ -190,18 +188,13 @@ impl oio::AppendObjectWrite for OssWriter {
let status = resp.status();
match status {
StatusCode::OK => {
- let position = resp
- .headers()
- .get(X_OSS_NEXT_APPEND_POSITION)
- .and_then(|v| v.to_str().ok())
- .and_then(|v| v.parse::<u64>().ok())
- .ok_or_else(|| {
- Error::new(
- ErrorKind::ConditionNotMatch,
- "missing x-oss-next-append-position, the object may not be appendable",
- )
- })?;
- Ok(position)
+ let content_length = parse_content_length(resp.headers())?.ok_or_else(|| {
+ Error::new(
+ ErrorKind::Unexpected,
+ "Content-Length not present in returning response",
+ )
+ })?;
+ Ok(content_length)
}
StatusCode::NOT_FOUND => Ok(0),
_ => Err(parse_error(resp).await?),