Skip to content

Commit

Permalink
feat: Conditional reader for azblob, gcs, oss (#5531)
Browse files Browse the repository at this point in the history
  • Loading branch information
geetanshjuneja authored Jan 13, 2025
1 parent 03b78f1 commit f951963
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 0 deletions.
2 changes: 2 additions & 0 deletions core/src/services/azblob/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,8 @@ impl Access for AzblobBackend {
read_with_if_match: true,
read_with_if_none_match: true,
read_with_override_content_disposition: true,
read_with_if_modified_since: true,
read_with_if_unmodified_since: true,

write: true,
write_can_append: true,
Expand Down
16 changes: 16 additions & 0 deletions core/src/services/azblob/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ use http::header::HeaderName;
use http::header::CONTENT_LENGTH;
use http::header::CONTENT_TYPE;
use http::header::IF_MATCH;
use http::header::IF_MODIFIED_SINCE;
use http::header::IF_NONE_MATCH;
use http::header::IF_UNMODIFIED_SINCE;
use http::HeaderValue;
use http::Request;
use http::Response;
Expand Down Expand Up @@ -208,6 +210,20 @@ impl AzblobCore {
req = req.header(IF_MATCH, if_match);
}

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

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

let req = req.body(Buffer::new()).map_err(new_request_build_error)?;

Ok(req)
Expand Down
2 changes: 2 additions & 0 deletions core/src/services/gcs/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,8 @@ impl Access for GcsBackend {

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
30 changes: 30 additions & 0 deletions core/src/services/gcs/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ use http::header::CONTENT_LENGTH;
use http::header::CONTENT_TYPE;
use http::header::HOST;
use http::header::IF_MATCH;
use http::header::IF_MODIFIED_SINCE;
use http::header::IF_NONE_MATCH;
use http::header::IF_UNMODIFIED_SINCE;
use http::Request;
use http::Response;
use once_cell::sync::Lazy;
Expand Down Expand Up @@ -201,6 +203,20 @@ impl GcsCore {
req = req.header(http::header::RANGE, range.to_header());
}

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

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

let req = req.body(Buffer::new()).map_err(new_request_build_error)?;

Ok(req)
Expand All @@ -221,6 +237,20 @@ impl GcsCore {
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,
format_datetime_into_http_date(if_modified_since),
);
}

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

let req = req.body(Buffer::new()).map_err(new_request_build_error)?;

Ok(req)
Expand Down
2 changes: 2 additions & 0 deletions core/src/services/oss/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,8 @@ impl Access for OssBackend {

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
16 changes: 16 additions & 0 deletions core/src/services/oss/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ use http::header::CONTENT_DISPOSITION;
use http::header::CONTENT_LENGTH;
use http::header::CONTENT_TYPE;
use http::header::IF_MATCH;
use http::header::IF_MODIFIED_SINCE;
use http::header::IF_NONE_MATCH;
use http::header::IF_UNMODIFIED_SINCE;
use http::header::RANGE;
use http::HeaderMap;
use http::HeaderName;
Expand Down Expand Up @@ -343,6 +345,20 @@ impl OssCore {
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,
format_datetime_into_http_date(if_modified_since),
);
}

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

let req = req.body(Buffer::new()).map_err(new_request_build_error)?;

Ok(req)
Expand Down

0 comments on commit f951963

Please sign in to comment.