Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(services/webdav): Use OpRead in webdav_get. #3081

Merged
merged 1 commit into from
Sep 15, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading