Skip to content

Commit

Permalink
refactor(services/webdav): Use OpRead in webdav_get. (#3081)
Browse files Browse the repository at this point in the history
  • Loading branch information
laipz8200 authored Sep 15, 2023
1 parent d30ff84 commit 87b3867
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions core/src/services/webdav/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ impl Accessor for WebdavBackend {
}

async fn read(&self, path: &str, args: OpRead) -> Result<(RpRead, Self::Reader)> {
let resp = self.webdav_get(path, args.range()).await?;
let resp = self.webdav_get(path, args).await?;
let status = resp.status();
match status {
StatusCode::OK | StatusCode::PARTIAL_CONTENT => {
Expand Down Expand Up @@ -408,11 +408,7 @@ impl Accessor for WebdavBackend {
}

impl WebdavBackend {
async fn webdav_get(
&self,
path: &str,
range: BytesRange,
) -> Result<Response<IncomingAsyncBody>> {
async fn webdav_get(&self, path: &str, args: OpRead) -> Result<Response<IncomingAsyncBody>> {
let p = build_rooted_abs_path(&self.root, path);
let url: String = format!("{}{}", self.endpoint, percent_encode_path(&p));

Expand All @@ -422,6 +418,7 @@ impl WebdavBackend {
req = req.header(header::AUTHORIZATION, auth.clone())
}

let range = args.range();
if !range.is_full() {
req = req.header(header::RANGE, range.to_header());
}
Expand Down

0 comments on commit 87b3867

Please sign in to comment.