-
Notifications
You must be signed in to change notification settings - Fork 505
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
feat(core): implement if_modified_since and if_unmodified_since for read_with and reader_with #5500
Conversation
Tests failed in |
minio should support those headers: minio/minio#1098 |
|
cbe9efb
to
ad7eac7
Compare
Ooops, it does have the requirement for |
core/tests/behavior/async_read.rs
Outdated
let bs = reader.read(..).await?.to_bytes(); | ||
assert_eq!(bs, content); | ||
|
||
sleep(Duration::from_secs(3)).await; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's better to remove this sleep.
core/tests/behavior/async_read.rs
Outdated
|
||
sleep(Duration::from_secs(3)).await; | ||
|
||
let one_second_ago_check = chrono::Utc::now() - chrono::Duration::seconds(1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about using chrono::Utc::now() + chrono::Duration::seconds(10)
? Also, the name one_second_ago_check
is incorrect. I recommend avoiding lengthy names; a simple since
should suffice.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe We can just use chrono::Utc::now()
here. but I'm not sure if this test will remain stable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By the way, Using a future time works for both Minio
and Ceph
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't make sense for the server to reject a future time. I believe AWS S3 is likely to support it, so we can give it a try.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've tested it in my local environment, and the result is the same as using the AWS CLI
. When using a future time in if-modified-since
, S3
always return a 200
status.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting. Ok, let's test in this way:
- Create a file.
- Retrieve its last modified time.
- Read it using
last_modified - 1s
(this should work). - Wait for 1 second.
- Attempt to read it using
last_modified + 1s
(this should result in an error).
What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, At least, this approach can help reduce the waiting time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Most changes look to me now, the only thing left here is the tests.
100e860
to
3176e2d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @meteorgan for working on this!
Which issue does this PR close?
Part of #5486.
Rationale for this change
What changes are included in this PR?
Are there any user-facing changes?
We'll add two methods
if_modified_since
andif_unmodified_since
forread_with
andreader_with
API