Skip to content
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion .github/services/webdav/0_nginx/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@ runs:
run: |
cat << EOF >> $GITHUB_ENV
OPENDAL_WEBDAV_ENDPOINT=http://127.0.0.1:8080
OPENDAL_TEST_CAPABILITY_OVERRIDES=write_with_user_metadata=false
OPENDAL_TEST_CAPABILITY_OVERRIDES=write_with_user_metadata=false,read_with_if_match=false,read_with_if_none_match=false,read_with_if_modified_since=false
EOF
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@ runs:
cat << EOF >> $GITHUB_ENV
OPENDAL_WEBDAV_ENDPOINT=http://127.0.0.1:8080
OPENDAL_WEBDAV_USERNAME=foo
OPENDAL_TEST_CAPABILITY_OVERRIDES=write_with_user_metadata=false
OPENDAL_TEST_CAPABILITY_OVERRIDES=write_with_user_metadata=false,read_with_if_match=false,read_with_if_none_match=false,read_with_if_modified_since=false
EOF
2 changes: 1 addition & 1 deletion .github/services/webdav/nginx_with_password/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@ runs:
OPENDAL_WEBDAV_ENDPOINT=http://127.0.0.1:8080
OPENDAL_WEBDAV_USERNAME=bar
OPENDAL_WEBDAV_PASSWORD=bar
OPENDAL_TEST_CAPABILITY_OVERRIDES=write_with_user_metadata=false
OPENDAL_TEST_CAPABILITY_OVERRIDES=write_with_user_metadata=false,read_with_if_match=false,read_with_if_none_match=false,read_with_if_modified_since=false
EOF
2 changes: 1 addition & 1 deletion .github/services/webdav/nginx_with_redirect/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@ runs:
run: |
cat << EOF >> $GITHUB_ENV
OPENDAL_WEBDAV_ENDPOINT=http://127.0.0.1:8081
OPENDAL_TEST_CAPABILITY_OVERRIDES=write_with_user_metadata=false
OPENDAL_TEST_CAPABILITY_OVERRIDES=write_with_user_metadata=false,read_with_if_match=false,read_with_if_none_match=false,read_with_if_modified_since=false
EOF
4 changes: 4 additions & 0 deletions core/services/webdav/src/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,10 @@ impl Builder for WebdavBuilder {
stat: true,

read: true,
read_with_if_match: true,
read_with_if_none_match: true,
read_with_if_modified_since: true,
read_with_if_unmodified_since: true,

write: true,
write_can_empty: true,
Expand Down
24 changes: 23 additions & 1 deletion core/services/webdav/src/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,13 +166,35 @@ impl WebdavCore {
&self,
path: &str,
range: BytesRange,
_: &OpRead,
args: &OpRead,
) -> Result<Response<HttpBody>> {
let path = build_rooted_abs_path(&self.root, path);
let url: String = format!("{}{}", self.endpoint, percent_encode_path(&path));

let mut req = Request::get(&url);

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

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

if let Some(if_modified_since) = args.if_modified_since() {
req = req.header(
header::IF_MODIFIED_SINCE,
if_modified_since.format_http_date(),
);
}

if let Some(if_unmodified_since) = args.if_unmodified_since() {
req = req.header(
header::IF_UNMODIFIED_SINCE,
if_unmodified_since.format_http_date(),
);
}

if let Some(auth) = &self.authorization {
req = req.header(header::AUTHORIZATION, auth.clone())
}
Expand Down
3 changes: 3 additions & 0 deletions core/services/webdav/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ pub(super) fn parse_error(resp: Response<Buffer>) -> Error {
StatusCode::NOT_FOUND => (ErrorKind::NotFound, false),
// Some services (like owncloud) return 403 while file locked.
StatusCode::FORBIDDEN => (ErrorKind::PermissionDenied, true),
StatusCode::PRECONDITION_FAILED | StatusCode::NOT_MODIFIED => {
(ErrorKind::ConditionNotMatch, false)
}
// Allowing retry for resource locked.
StatusCode::LOCKED => (ErrorKind::Unexpected, true),
StatusCode::INTERNAL_SERVER_ERROR
Expand Down
Loading