Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
6 changes: 5 additions & 1 deletion bindings/python/tests/test_read.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,11 @@ async def test_async_read_not_exists(service_name, operator, async_operator):


@pytest.mark.need_capability(
"read", "read_with_if_modified_since", "read_with_if_unmodified_since"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, what does this change for python binding?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

without this change, enabling read_with_if_modified_since / read_with_if_unmodified_since on the HTTP service makes test_sync_conditional_reads newly match the HTTP backend via need_capability, then crash on operator.write() since HTTP is read-only. Adding write / delete to the gate aligns it with what the test body actually does and keeps the test skipped on read-only backends

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. We can skip delete here. And we probably don't need to clean up explicitly.

"read",
"write",
"delete",
"read_with_if_modified_since",
"read_with_if_unmodified_since",
)
def test_sync_conditional_reads(service_name, operator):
path = f"random_file_{str(uuid4())}"
Expand Down
4 changes: 4 additions & 0 deletions core/services/http/src/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,12 +133,16 @@ impl Builder for HttpBuilder {
stat: true,
stat_with_if_match: true,
stat_with_if_none_match: true,
stat_with_if_modified_since: true,
stat_with_if_unmodified_since: true,

read: true,
read_with_suffix: true,

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

presign: auth.is_none(),
presign_read: auth.is_none(),
Expand Down
18 changes: 18 additions & 0 deletions core/services/http/src/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ use http::Request;
use http::Response;
use http::header;
use http::header::IF_MATCH;
use http::header::IF_MODIFIED_SINCE;
use http::header::IF_NONE_MATCH;
use http::header::IF_UNMODIFIED_SINCE;

use opendal_core::raw::*;
use opendal_core::*;
Expand Down Expand Up @@ -70,6 +72,14 @@ impl HttpCore {
req = req.header(IF_NONE_MATCH, if_none_match);
}

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

if let Some(if_unmodified_since) = args.if_unmodified_since() {
req = req.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 Expand Up @@ -111,6 +121,14 @@ impl HttpCore {
req = req.header(IF_NONE_MATCH, if_none_match);
}

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

if let Some(if_unmodified_since) = args.if_unmodified_since() {
req = req.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
Loading