criccomini commented on code in PR #743:
URL:
https://github.com/apache/arrow-rs-object-store/pull/743#discussion_r3384469346
##########
src/aws/client.rs:
##########
@@ -1380,4 +1386,114 @@ mod tests {
.unwrap();
mock.shutdown().await;
}
+
+ /// A marker inserted into response extensions by [`MarkerMiddleware`]
+ #[derive(Clone, Debug, PartialEq)]
+ struct Marker(usize);
+
+ /// [`HttpService`] middleware that tags every response with a [`Marker`]
+ ///
+ /// [`HttpService`]: crate::client::HttpService
+ #[derive(Debug)]
+ struct MarkerMiddleware(reqwest::Client);
+
+ #[async_trait]
+ impl crate::client::HttpService for MarkerMiddleware {
+ async fn call(
+ &self,
+ req: crate::client::HttpRequest,
+ ) -> Result<HttpResponse, HttpError> {
+ let mut response = crate::client::HttpService::call(&self.0,
req).await?;
+ response.extensions_mut().insert(Marker(42));
+ Ok(response)
+ }
+ }
+
+ #[tokio::test]
+ async fn test_response_extensions_propagated() {
Review Comment:
This is the only test. Not sure if you want to clutter up the other ones
with tests as well. Can do so if desired.
##########
src/http/client.rs:
##########
@@ -415,6 +419,9 @@ impl GetClient for Client {
#[derive(Deserialize, Default)]
pub(crate) struct MultiStatus {
pub response: Vec<MultiStatusResponse>,
+ /// The extensions of the HTTP response this was parsed from
+ #[serde(skip)]
+ pub extensions: ::http::Extensions,
Review Comment:
I like this style vs. returning a `(MultiStatus, Extensions)` for `list`.
LMK if you prefer the tuple.
##########
src/client/header.rs:
##########
@@ -70,15 +70,22 @@ pub(crate) enum Error {
},
}
-/// Extracts a PutResult from the provided [`HeaderMap`]
+/// Extracts a PutResult from the provided response
+///
+/// Propagates the extensions of the response into the [`PutResult`]
#[cfg(any(feature = "aws", feature = "gcp", feature = "azure"))]
pub(crate) fn get_put_result(
- headers: &HeaderMap,
+ response: crate::client::HttpResponse,
Review Comment:
Different ways to tackle this. LMK if you prefer another approach. Fable
initially did a `mut` here which was kinda gross.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]