Skip to content

Commit

Permalink
enable read for webdav
Browse files Browse the repository at this point in the history
Signed-off-by: suyanhanx <[email protected]>
  • Loading branch information
suyanhanx committed Apr 27, 2023
1 parent c084c60 commit addb518
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion core/src/services/webdav/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -267,12 +267,18 @@ impl Accessor for WebdavBackend {
ma.set_scheme(Scheme::Webdav)
.set_root(&self.root)
.set_capability(Capability {
stat: true,

read: true,
read_can_next: true,
read_with_if_match: true,
read_with_if_none_match: true,

write: true,
list: true,
copy: true,
rename: true,

..Default::default()
});

Expand All @@ -287,7 +293,9 @@ 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.range(), args.if_match(), args.if_none_match())
.await?;

let status = resp.status();

Expand Down Expand Up @@ -430,6 +438,8 @@ impl WebdavBackend {
&self,
path: &str,
range: BytesRange,
if_match: Option<&str>,
if_none_match: Option<&str>,
) -> Result<Response<IncomingAsyncBody>> {
let p = build_rooted_abs_path(&self.root, path);

Expand All @@ -445,6 +455,13 @@ impl WebdavBackend {
req = req.header(header::RANGE, range.to_header());
}

if let Some(etag) = if_match {
req = req.header(header::IF_MATCH, etag);
}
if let Some(etag) = if_none_match {
req = req.header(header::IF_NONE_MATCH, etag);
}

let req = req
.body(AsyncBody::Empty)
.map_err(new_request_build_error)?;
Expand Down

0 comments on commit addb518

Please sign in to comment.