-
Notifications
You must be signed in to change notification settings - Fork 157
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
Return the new object ETag in PutObjectResult #1057
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
use std::str::FromStr; | ||
use std::string::ParseError; | ||
|
||
/// An ETag (entity tag) is a unique identifier for a HTTP object. | ||
/// | ||
/// New ETags can be created with the [`FromStr`] implementation. | ||
#[derive(Debug, Clone, Hash, PartialEq, Eq)] | ||
pub struct ETag(String); | ||
|
||
impl ETag { | ||
/// Get the ETag as a string | ||
pub fn as_str(&self) -> &str { | ||
&self.0 | ||
} | ||
|
||
/// Unpack the [String] contained by the [ETag] wrapper | ||
pub fn into_inner(self) -> String { | ||
self.0 | ||
} | ||
|
||
/// Creating default etag for tests | ||
#[doc(hidden)] | ||
pub fn for_tests() -> Self { | ||
Self("test_etag".to_string()) | ||
} | ||
|
||
/// Creating unique etag from bytes | ||
#[doc(hidden)] | ||
#[cfg(feature = "mock")] | ||
pub fn from_object_bytes(data: &[u8]) -> Self { | ||
use md5::Digest as _; | ||
|
||
let mut hasher = md5::Md5::new(); | ||
hasher.update(data); | ||
|
||
let hash = hasher.finalize(); | ||
let result = format!("{:x}", hash); | ||
Self(result) | ||
} | ||
} | ||
|
||
impl FromStr for ETag { | ||
type Err = ParseError; | ||
fn from_str(value: &str) -> Result<Self, Self::Err> { | ||
let etag = value.to_string(); | ||
Ok(ETag(etag)) | ||
} | ||
} | ||
|
||
impl<S: AsRef<str>> From<S> for ETag { | ||
fn from(value: S) -> Self { | ||
Self(value.as_ref().to_string()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 would prefer
response_headers_receiver
and update the comment.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.
Pushing back a little on this. A
Receiver
is a future and that's how it is used here. But happy to clarify in the comment.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 just not clear from the naming that we have to call
.await
to really get the headers, but not blocking on it.