diff --git a/core/src/services/aliyun_drive/error.rs b/core/src/services/aliyun_drive/error.rs index 8c06b988a757..fc90cfcd814b 100644 --- a/core/src/services/aliyun_drive/error.rs +++ b/core/src/services/aliyun_drive/error.rs @@ -28,8 +28,8 @@ struct AliyunDriveError { } pub(super) fn parse_error(res: Response) -> Error { - let (parts, mut body) = res.into_parts(); - let bs = body.copy_to_bytes(body.remaining()); + let (parts, body) = res.into_parts(); + let bs = body.to_bytes(); let (code, message) = serde_json::from_reader::<_, AliyunDriveError>(bs.clone().reader()) .map(|err| (Some(err.code), err.message)) .unwrap_or((None, String::from_utf8_lossy(&bs).into_owned())); diff --git a/core/src/services/alluxio/error.rs b/core/src/services/alluxio/error.rs index 6b7da11d2ae6..71935cee799e 100644 --- a/core/src/services/alluxio/error.rs +++ b/core/src/services/alluxio/error.rs @@ -32,8 +32,8 @@ struct AlluxioError { } pub(super) fn parse_error(resp: Response) -> Error { - let (parts, mut body) = resp.into_parts(); - let bs = body.copy_to_bytes(body.remaining()); + let (parts, body) = resp.into_parts(); + let bs = body.to_bytes(); let mut kind = match parts.status.as_u16() { 500 => ErrorKind::Unexpected, diff --git a/core/src/services/azdls/error.rs b/core/src/services/azdls/error.rs index 95e09bf88985..7ba598160930 100644 --- a/core/src/services/azdls/error.rs +++ b/core/src/services/azdls/error.rs @@ -60,8 +60,8 @@ impl Debug for AzdlsError { /// Parse error response into Error. pub(super) fn parse_error(resp: Response) -> Error { - let (parts, mut body) = resp.into_parts(); - let bs = body.copy_to_bytes(body.remaining()); + let (parts, body) = resp.into_parts(); + let bs = body.to_bytes(); let (kind, retryable) = match parts.status { StatusCode::NOT_FOUND => (ErrorKind::NotFound, false), diff --git a/core/src/services/azfile/error.rs b/core/src/services/azfile/error.rs index 63f8b933fff8..bd0cf9042f01 100644 --- a/core/src/services/azfile/error.rs +++ b/core/src/services/azfile/error.rs @@ -60,8 +60,8 @@ impl Debug for AzfileError { /// Parse error response into Error. pub(super) fn parse_error(resp: Response) -> Error { - let (parts, mut body) = resp.into_parts(); - let bs = body.copy_to_bytes(body.remaining()); + let (parts, body) = resp.into_parts(); + let bs = body.to_bytes(); let (kind, retryable) = match parts.status { StatusCode::NOT_FOUND => (ErrorKind::NotFound, false), diff --git a/core/src/services/b2/error.rs b/core/src/services/b2/error.rs index 678b5bb8386e..4c23282693d7 100644 --- a/core/src/services/b2/error.rs +++ b/core/src/services/b2/error.rs @@ -33,8 +33,8 @@ struct B2Error { /// Parse error response into Error. pub(super) fn parse_error(resp: Response) -> Error { - let (parts, mut body) = resp.into_parts(); - let bs = body.copy_to_bytes(body.remaining()); + let (parts, body) = resp.into_parts(); + let bs = body.to_bytes(); let (mut kind, mut retryable) = match parts.status.as_u16() { 403 => (ErrorKind::PermissionDenied, false), diff --git a/core/src/services/chainsafe/error.rs b/core/src/services/chainsafe/error.rs index 2a546c314bb2..87f78e40ca4f 100644 --- a/core/src/services/chainsafe/error.rs +++ b/core/src/services/chainsafe/error.rs @@ -37,8 +37,8 @@ struct ChainsafeSubError { /// Parse error response into Error. pub(super) fn parse_error(resp: Response) -> Error { - let (parts, mut body) = resp.into_parts(); - let bs = body.copy_to_bytes(body.remaining()); + let (parts, body) = resp.into_parts(); + let bs = body.to_bytes(); let (kind, retryable) = match parts.status.as_u16() { 401 | 403 => (ErrorKind::PermissionDenied, false), diff --git a/core/src/services/cloudflare_kv/error.rs b/core/src/services/cloudflare_kv/error.rs index 79a7b0dfcc0a..b04eb3e57e46 100644 --- a/core/src/services/cloudflare_kv/error.rs +++ b/core/src/services/cloudflare_kv/error.rs @@ -27,8 +27,8 @@ use crate::*; /// Parse error response into Error. pub(super) fn parse_error(resp: Response) -> Error { - let (parts, mut body) = resp.into_parts(); - let bs = body.copy_to_bytes(body.remaining()); + let (parts, body) = resp.into_parts(); + let bs = body.to_bytes(); let (mut kind, mut retryable) = match parts.status { StatusCode::NOT_FOUND => (ErrorKind::NotFound, false), diff --git a/core/src/services/cos/error.rs b/core/src/services/cos/error.rs index df5f95df5cca..4d767e2771cd 100644 --- a/core/src/services/cos/error.rs +++ b/core/src/services/cos/error.rs @@ -37,8 +37,8 @@ struct CosError { /// Parse error response into Error. pub(super) fn parse_error(resp: Response) -> Error { - let (parts, mut body) = resp.into_parts(); - let bs = body.copy_to_bytes(body.remaining()); + let (parts, body) = resp.into_parts(); + let bs = body.to_bytes(); let (kind, retryable) = match parts.status { StatusCode::NOT_FOUND => (ErrorKind::NotFound, false), diff --git a/core/src/services/d1/backend.rs b/core/src/services/d1/backend.rs index a86d47ab8862..b6897aa3ef51 100644 --- a/core/src/services/d1/backend.rs +++ b/core/src/services/d1/backend.rs @@ -18,7 +18,6 @@ use std::fmt::Debug; use std::fmt::Formatter; -use bytes::Buf; use http::header; use http::Request; use http::StatusCode; @@ -287,8 +286,8 @@ impl kv::Adapter for Adapter { let status = resp.status(); match status { StatusCode::OK | StatusCode::PARTIAL_CONTENT => { - let mut body = resp.into_body(); - let bs = body.copy_to_bytes(body.remaining()); + let body = resp.into_body(); + let bs = body.to_bytes(); let d1_response = D1Response::parse(&bs)?; Ok(d1_response.get_result(&self.value_field)) } diff --git a/core/src/services/d1/error.rs b/core/src/services/d1/error.rs index f9cdf66b23e8..37f6b95564e9 100644 --- a/core/src/services/d1/error.rs +++ b/core/src/services/d1/error.rs @@ -27,8 +27,8 @@ use crate::*; /// Parse error response into Error. pub(super) fn parse_error(resp: Response) -> Error { - let (parts, mut body) = resp.into_parts(); - let bs = body.copy_to_bytes(body.remaining()); + let (parts, body) = resp.into_parts(); + let bs = body.to_bytes(); let (mut kind, mut retryable) = match parts.status { StatusCode::NOT_FOUND => (ErrorKind::NotFound, false), diff --git a/core/src/services/dbfs/error.rs b/core/src/services/dbfs/error.rs index ca5b3a2c20b8..666466b727ac 100644 --- a/core/src/services/dbfs/error.rs +++ b/core/src/services/dbfs/error.rs @@ -17,7 +17,6 @@ use std::fmt::Debug; -use bytes::Buf; use http::Response; use http::StatusCode; use serde::Deserialize; @@ -44,8 +43,8 @@ impl Debug for DbfsError { } pub(super) fn parse_error(resp: Response) -> Error { - let (parts, mut body) = resp.into_parts(); - let bs = body.copy_to_bytes(body.remaining()); + let (parts, body) = resp.into_parts(); + let bs = body.to_bytes(); let (kind, retryable) = match parts.status { StatusCode::NOT_FOUND => (ErrorKind::NotFound, false), diff --git a/core/src/services/dropbox/error.rs b/core/src/services/dropbox/error.rs index ec242c6f7f96..715d029ed8bf 100644 --- a/core/src/services/dropbox/error.rs +++ b/core/src/services/dropbox/error.rs @@ -15,7 +15,6 @@ // specific language governing permissions and limitations // under the License. -use bytes::Buf; use http::Response; use http::StatusCode; use serde::Deserialize; @@ -31,8 +30,8 @@ pub struct DropboxErrorResponse { /// Parse error response into Error. pub(super) fn parse_error(resp: Response) -> Error { - let (parts, mut body) = resp.into_parts(); - let bs = body.copy_to_bytes(body.remaining()); + let (parts, body) = resp.into_parts(); + let bs = body.to_bytes(); let (mut kind, mut retryable) = match parts.status { StatusCode::NOT_FOUND => (ErrorKind::NotFound, false), diff --git a/core/src/services/gdrive/error.rs b/core/src/services/gdrive/error.rs index 94e00789f5ca..199e82e26a8a 100644 --- a/core/src/services/gdrive/error.rs +++ b/core/src/services/gdrive/error.rs @@ -15,7 +15,6 @@ // specific language governing permissions and limitations // under the License. -use bytes::Buf; use http::Response; use http::StatusCode; use serde::Deserialize; @@ -35,8 +34,8 @@ struct GdriveInnerError { /// Parse error response into Error. pub(super) fn parse_error(resp: Response) -> Error { - let (parts, mut body) = resp.into_parts(); - let bs = body.copy_to_bytes(body.remaining()); + let (parts, body) = resp.into_parts(); + let bs = body.to_bytes(); let (mut kind, mut retryable) = match parts.status { StatusCode::NOT_FOUND => (ErrorKind::NotFound, false), diff --git a/core/src/services/ghac/error.rs b/core/src/services/ghac/error.rs index a2736e05b657..7efafe1f6dd7 100644 --- a/core/src/services/ghac/error.rs +++ b/core/src/services/ghac/error.rs @@ -15,7 +15,6 @@ // specific language governing permissions and limitations // under the License. -use bytes::Buf; use http::Response; use http::StatusCode; @@ -24,7 +23,7 @@ use crate::*; /// Parse error response into Error. pub(super) fn parse_error(resp: Response) -> Error { - let (parts, mut body) = resp.into_parts(); + let (parts, body) = resp.into_parts(); let (kind, retryable) = match parts.status { StatusCode::NOT_FOUND | StatusCode::NO_CONTENT => (ErrorKind::NotFound, false), @@ -38,7 +37,7 @@ pub(super) fn parse_error(resp: Response) -> Error { _ => (ErrorKind::Unexpected, false), }; - let bs = body.copy_to_bytes(body.remaining()); + let bs = body.to_bytes(); let message = String::from_utf8_lossy(&bs); let mut err = Error::new(kind, message); diff --git a/core/src/services/github/error.rs b/core/src/services/github/error.rs index 3109370ad3df..cfc259c111e7 100644 --- a/core/src/services/github/error.rs +++ b/core/src/services/github/error.rs @@ -37,8 +37,8 @@ struct GithubSubError { /// Parse error response into Error. pub(super) fn parse_error(resp: Response) -> Error { - let (parts, mut body) = resp.into_parts(); - let bs = body.copy_to_bytes(body.remaining()); + let (parts, body) = resp.into_parts(); + let bs = body.to_bytes(); let (kind, retryable) = match parts.status.as_u16() { 401 | 403 => (ErrorKind::PermissionDenied, false), diff --git a/core/src/services/http/error.rs b/core/src/services/http/error.rs index e2c2947f8932..09150089232b 100644 --- a/core/src/services/http/error.rs +++ b/core/src/services/http/error.rs @@ -15,7 +15,6 @@ // specific language governing permissions and limitations // under the License. -use bytes::Buf; use http::Response; use http::StatusCode; @@ -24,8 +23,8 @@ use crate::*; /// Parse error response into Error. pub(super) fn parse_error(resp: Response) -> Error { - let (parts, mut body) = resp.into_parts(); - let bs = body.copy_to_bytes(body.remaining()); + let (parts, body) = resp.into_parts(); + let bs = body.to_bytes(); let (kind, retryable) = match parts.status { StatusCode::NOT_FOUND => (ErrorKind::NotFound, false), diff --git a/core/src/services/huggingface/error.rs b/core/src/services/huggingface/error.rs index 61abc2c25d1a..e69a70a257ed 100644 --- a/core/src/services/huggingface/error.rs +++ b/core/src/services/huggingface/error.rs @@ -17,7 +17,6 @@ use std::fmt::Debug; -use bytes::Buf; use http::Response; use http::StatusCode; use serde::Deserialize; @@ -41,8 +40,8 @@ impl Debug for HuggingfaceError { } pub(super) fn parse_error(resp: Response) -> Error { - let (parts, mut body) = resp.into_parts(); - let bs = body.copy_to_bytes(body.remaining()); + let (parts, body) = resp.into_parts(); + let bs = body.to_bytes(); let (kind, retryable) = match parts.status { StatusCode::NOT_FOUND => (ErrorKind::NotFound, false), diff --git a/core/src/services/icloud/core.rs b/core/src/services/icloud/core.rs index 1028ba9f657e..328a30af3127 100644 --- a/core/src/services/icloud/core.rs +++ b/core/src/services/icloud/core.rs @@ -569,8 +569,8 @@ impl PathQuery for IcloudPathQuery { } pub(super) fn parse_error(resp: Response) -> Error { - let (parts, mut body) = resp.into_parts(); - let bs = body.copy_to_bytes(body.remaining()); + let (parts, body) = resp.into_parts(); + let bs = body.to_bytes(); let mut kind = match parts.status.as_u16() { 421 | 450 | 500 => ErrorKind::NotFound, diff --git a/core/src/services/ipfs/error.rs b/core/src/services/ipfs/error.rs index 9f7e183160b0..e47eda369d77 100644 --- a/core/src/services/ipfs/error.rs +++ b/core/src/services/ipfs/error.rs @@ -15,7 +15,6 @@ // specific language governing permissions and limitations // under the License. -use bytes::Buf; use http::Response; use http::StatusCode; @@ -24,8 +23,8 @@ use crate::*; /// Parse error response into Error. pub(super) fn parse_error(resp: Response) -> Error { - let (parts, mut body) = resp.into_parts(); - let bs = body.copy_to_bytes(body.remaining()); + let (parts, body) = resp.into_parts(); + let bs = body.to_bytes(); let (kind, retryable) = match parts.status { StatusCode::NOT_FOUND => (ErrorKind::NotFound, false), diff --git a/core/src/services/ipmfs/error.rs b/core/src/services/ipmfs/error.rs index 780e3388a4bd..395b4e710447 100644 --- a/core/src/services/ipmfs/error.rs +++ b/core/src/services/ipmfs/error.rs @@ -15,7 +15,6 @@ // specific language governing permissions and limitations // under the License. -use bytes::Buf; use http::Response; use http::StatusCode; use serde::Deserialize; @@ -45,8 +44,8 @@ struct IpfsError { /// /// ref: https://docs.ipfs.tech/reference/kubo/rpc/#http-status-codes pub(super) fn parse_error(resp: Response) -> Error { - let (parts, mut body) = resp.into_parts(); - let bs = body.copy_to_bytes(body.remaining()); + let (parts, body) = resp.into_parts(); + let bs = body.to_bytes(); let ipfs_error = de::from_slice::(&bs).ok(); diff --git a/core/src/services/koofr/error.rs b/core/src/services/koofr/error.rs index 7929c2de3775..760f201194a0 100644 --- a/core/src/services/koofr/error.rs +++ b/core/src/services/koofr/error.rs @@ -15,7 +15,6 @@ // specific language governing permissions and limitations // under the License. -use bytes::Buf; use http::Response; use crate::raw::*; @@ -23,8 +22,8 @@ use crate::*; /// Parse error response into Error. pub(super) fn parse_error(resp: Response) -> Error { - let (parts, mut body) = resp.into_parts(); - let bs = body.copy_to_bytes(body.remaining()); + let (parts, body) = resp.into_parts(); + let bs = body.to_bytes(); let (kind, retryable) = match parts.status.as_u16() { 403 => (ErrorKind::PermissionDenied, false), diff --git a/core/src/services/lakefs/error.rs b/core/src/services/lakefs/error.rs index 32c75d888408..69934d747b8a 100644 --- a/core/src/services/lakefs/error.rs +++ b/core/src/services/lakefs/error.rs @@ -17,7 +17,6 @@ use std::fmt::Debug; -use bytes::Buf; use http::Response; use http::StatusCode; use serde::Deserialize; @@ -41,8 +40,8 @@ impl Debug for LakefsError { } pub(super) fn parse_error(resp: Response) -> Error { - let (parts, mut body) = resp.into_parts(); - let bs = body.copy_to_bytes(body.remaining()); + let (parts, body) = resp.into_parts(); + let bs = body.to_bytes(); let (kind, retryable) = match parts.status { StatusCode::NOT_FOUND => (ErrorKind::NotFound, false), diff --git a/core/src/services/libsql/error.rs b/core/src/services/libsql/error.rs index 8019ce29a801..54af90a53702 100644 --- a/core/src/services/libsql/error.rs +++ b/core/src/services/libsql/error.rs @@ -15,7 +15,6 @@ // specific language governing permissions and limitations // under the License. -use bytes::Buf; use http::Response; use http::StatusCode; @@ -24,8 +23,8 @@ use crate::*; /// Parse error response into Error. pub(super) fn parse_error(resp: Response) -> Error { - let (parts, mut body) = resp.into_parts(); - let bs = body.copy_to_bytes(body.remaining()); + let (parts, body) = resp.into_parts(); + let bs = body.to_bytes(); let (kind, retryable) = match parts.status { StatusCode::NOT_FOUND => (ErrorKind::NotFound, false), diff --git a/core/src/services/obs/error.rs b/core/src/services/obs/error.rs index f67afdae5c7a..21ddd5f97d7b 100644 --- a/core/src/services/obs/error.rs +++ b/core/src/services/obs/error.rs @@ -37,8 +37,8 @@ struct ObsError { /// Parse error response into Error. pub(super) fn parse_error(resp: Response) -> Error { - let (parts, mut body) = resp.into_parts(); - let bs = body.copy_to_bytes(body.remaining()); + let (parts, body) = resp.into_parts(); + let bs = body.to_bytes(); let (kind, retryable) = match parts.status { StatusCode::NOT_FOUND => (ErrorKind::NotFound, false), diff --git a/core/src/services/onedrive/error.rs b/core/src/services/onedrive/error.rs index ab396a499d3f..8564eedc606e 100644 --- a/core/src/services/onedrive/error.rs +++ b/core/src/services/onedrive/error.rs @@ -15,7 +15,6 @@ // specific language governing permissions and limitations // under the License. -use bytes::Buf; use http::Response; use http::StatusCode; @@ -24,8 +23,8 @@ use crate::*; /// Parse error response into Error. pub(super) fn parse_error(resp: Response) -> Error { - let (parts, mut body) = resp.into_parts(); - let bs = body.copy_to_bytes(body.remaining()); + let (parts, body) = resp.into_parts(); + let bs = body.to_bytes(); let (kind, retryable) = match parts.status { StatusCode::NOT_FOUND => (ErrorKind::NotFound, false), diff --git a/core/src/services/onedrive/writer.rs b/core/src/services/onedrive/writer.rs index f2a35d1e57dd..c6ed61f22c4f 100644 --- a/core/src/services/onedrive/writer.rs +++ b/core/src/services/onedrive/writer.rs @@ -122,7 +122,7 @@ impl OneDriveWriter { } async fn create_upload_session(&self) -> Result { - let file_name_from_path = self.path.split('/').last().ok_or_else(|| { + let file_name_from_path = self.path.split('/').next_back().ok_or_else(|| { Error::new( ErrorKind::Unexpected, "connection string must have AccountName", diff --git a/core/src/services/oss/error.rs b/core/src/services/oss/error.rs index 3cfeb66b0c25..9173d5026430 100644 --- a/core/src/services/oss/error.rs +++ b/core/src/services/oss/error.rs @@ -36,8 +36,8 @@ struct OssError { /// Parse error response into Error. pub(super) fn parse_error(resp: Response) -> Error { - let (parts, mut body) = resp.into_parts(); - let bs = body.copy_to_bytes(body.remaining()); + let (parts, body) = resp.into_parts(); + let bs = body.to_bytes(); let (kind, retryable) = match parts.status { StatusCode::NOT_FOUND => (ErrorKind::NotFound, false), diff --git a/core/src/services/pcloud/error.rs b/core/src/services/pcloud/error.rs index 2b1f3edbe3ee..1234df1e2f7d 100644 --- a/core/src/services/pcloud/error.rs +++ b/core/src/services/pcloud/error.rs @@ -18,7 +18,6 @@ use std::fmt::Debug; use std::fmt::Formatter; -use bytes::Buf; use http::Response; use serde::Deserialize; @@ -43,8 +42,8 @@ impl Debug for PcloudError { /// Parse error response into Error. pub(super) fn parse_error(resp: Response) -> Error { - let (parts, mut body) = resp.into_parts(); - let bs = body.copy_to_bytes(body.remaining()); + let (parts, body) = resp.into_parts(); + let bs = body.to_bytes(); let message = String::from_utf8_lossy(&bs).into_owned(); let mut err = Error::new(ErrorKind::Unexpected, message); diff --git a/core/src/services/s3/backend.rs b/core/src/services/s3/backend.rs index 3f3f00521aae..9145f22a7c8b 100644 --- a/core/src/services/s3/backend.rs +++ b/core/src/services/s3/backend.rs @@ -751,10 +751,10 @@ impl Builder for S3Builder { let checksum_algorithm = match self.config.checksum_algorithm.as_deref() { Some("crc32c") => Some(ChecksumAlgorithm::Crc32c), None => None, - _ => { + v => { return Err(Error::new( ErrorKind::ConfigInvalid, - "{v} is not a supported checksum_algorithm.", + format!("{:?} is not a supported checksum_algorithm.", v), )) } }; diff --git a/core/src/services/seafile/error.rs b/core/src/services/seafile/error.rs index ab0bf6588c0a..47a7bde5358a 100644 --- a/core/src/services/seafile/error.rs +++ b/core/src/services/seafile/error.rs @@ -31,8 +31,8 @@ struct SeafileError { /// Parse error response into Error. pub(super) fn parse_error(resp: Response) -> Error { - let (parts, mut body) = resp.into_parts(); - let bs = body.copy_to_bytes(body.remaining()); + let (parts, body) = resp.into_parts(); + let bs = body.to_bytes(); let (kind, _retryable) = match parts.status.as_u16() { 403 => (ErrorKind::PermissionDenied, false), diff --git a/core/src/services/supabase/error.rs b/core/src/services/supabase/error.rs index c2316eab8c71..273addb90415 100644 --- a/core/src/services/supabase/error.rs +++ b/core/src/services/supabase/error.rs @@ -15,7 +15,6 @@ // specific language governing permissions and limitations // under the License. -use bytes::Buf; use http::Response; use http::StatusCode; use serde::Deserialize; @@ -35,8 +34,8 @@ struct SupabaseError { /// Parse the supabase error type to the OpenDAL error type pub(super) fn parse_error(resp: Response) -> Error { - let (parts, mut body) = resp.into_parts(); - let bs = body.copy_to_bytes(body.remaining()); + let (parts, body) = resp.into_parts(); + let bs = body.to_bytes(); // Check HTTP status code first/ let (mut kind, mut retryable) = match parts.status.as_u16() { diff --git a/core/src/services/swift/error.rs b/core/src/services/swift/error.rs index 73afa41645c7..3bbb25f88154 100644 --- a/core/src/services/swift/error.rs +++ b/core/src/services/swift/error.rs @@ -33,8 +33,8 @@ struct ErrorResponse { } pub(super) fn parse_error(resp: Response) -> Error { - let (parts, mut body) = resp.into_parts(); - let bs = body.copy_to_bytes(body.remaining()); + let (parts, body) = resp.into_parts(); + let bs = body.to_bytes(); let (kind, retryable) = match parts.status { StatusCode::NOT_FOUND => (ErrorKind::NotFound, false), diff --git a/core/src/services/upyun/error.rs b/core/src/services/upyun/error.rs index 317ea061dfdc..3a8567cd72e0 100644 --- a/core/src/services/upyun/error.rs +++ b/core/src/services/upyun/error.rs @@ -34,8 +34,8 @@ struct UpyunError { /// Parse error response into Error. pub(super) fn parse_error(resp: Response) -> Error { - let (parts, mut body) = resp.into_parts(); - let bs = body.copy_to_bytes(body.remaining()); + let (parts, body) = resp.into_parts(); + let bs = body.to_bytes(); let (kind, retryable) = match parts.status.as_u16() { 403 => (ErrorKind::PermissionDenied, false), diff --git a/core/src/services/vercel_artifacts/error.rs b/core/src/services/vercel_artifacts/error.rs index ab396a499d3f..8564eedc606e 100644 --- a/core/src/services/vercel_artifacts/error.rs +++ b/core/src/services/vercel_artifacts/error.rs @@ -15,7 +15,6 @@ // specific language governing permissions and limitations // under the License. -use bytes::Buf; use http::Response; use http::StatusCode; @@ -24,8 +23,8 @@ use crate::*; /// Parse error response into Error. pub(super) fn parse_error(resp: Response) -> Error { - let (parts, mut body) = resp.into_parts(); - let bs = body.copy_to_bytes(body.remaining()); + let (parts, body) = resp.into_parts(); + let bs = body.to_bytes(); let (kind, retryable) = match parts.status { StatusCode::NOT_FOUND => (ErrorKind::NotFound, false), diff --git a/core/src/services/vercel_blob/error.rs b/core/src/services/vercel_blob/error.rs index 29ecced517f3..58f9420a1ac5 100644 --- a/core/src/services/vercel_blob/error.rs +++ b/core/src/services/vercel_blob/error.rs @@ -39,8 +39,8 @@ struct VercelBlobErrorDetail { /// Parse error response into Error. pub(super) fn parse_error(resp: Response) -> Error { - let (parts, mut body) = resp.into_parts(); - let bs = body.copy_to_bytes(body.remaining()); + let (parts, body) = resp.into_parts(); + let bs = body.to_bytes(); let (kind, retryable) = match parts.status.as_u16() { 403 => (ErrorKind::PermissionDenied, false), diff --git a/core/src/services/webdav/error.rs b/core/src/services/webdav/error.rs index 0fa32efe814f..bc3f2f4b3bfd 100644 --- a/core/src/services/webdav/error.rs +++ b/core/src/services/webdav/error.rs @@ -15,7 +15,6 @@ // specific language governing permissions and limitations // under the License. -use bytes::Buf; use http::Response; use http::StatusCode; @@ -24,8 +23,8 @@ use crate::*; /// Parse error response into Error. pub(super) fn parse_error(resp: Response) -> Error { - let (parts, mut body) = resp.into_parts(); - let bs = body.copy_to_bytes(body.remaining()); + let (parts, body) = resp.into_parts(); + let bs = body.to_bytes(); let (kind, retryable) = match parts.status { StatusCode::NOT_FOUND => (ErrorKind::NotFound, false), diff --git a/core/src/services/webhdfs/error.rs b/core/src/services/webhdfs/error.rs index 1a3a486f7e6e..2dd8ecb664d4 100644 --- a/core/src/services/webhdfs/error.rs +++ b/core/src/services/webhdfs/error.rs @@ -15,7 +15,6 @@ // specific language governing permissions and limitations // under the License. -use bytes::Buf; use http::response::Parts; use http::Response; use http::StatusCode; @@ -41,8 +40,8 @@ struct WebHdfsError { } pub(super) fn parse_error(resp: Response) -> Error { - let (parts, mut body) = resp.into_parts(); - let bs = body.copy_to_bytes(body.remaining()); + let (parts, body) = resp.into_parts(); + let bs = body.to_bytes(); let s = String::from_utf8_lossy(&bs); parse_error_msg(parts, &s) } diff --git a/core/src/services/yandex_disk/error.rs b/core/src/services/yandex_disk/error.rs index 1f36284453ad..78c397548127 100644 --- a/core/src/services/yandex_disk/error.rs +++ b/core/src/services/yandex_disk/error.rs @@ -34,8 +34,8 @@ struct YandexDiskError { /// Parse error response into Error. pub(super) fn parse_error(resp: Response) -> Error { - let (parts, mut body) = resp.into_parts(); - let bs = body.copy_to_bytes(body.remaining()); + let (parts, body) = resp.into_parts(); + let bs = body.to_bytes(); let (kind, retryable) = match parts.status.as_u16() { 410 | 403 => (ErrorKind::PermissionDenied, false),