diff --git a/object_store/Cargo.toml b/object_store/Cargo.toml index 7e512458344..0372514dba7 100644 --- a/object_store/Cargo.toml +++ b/object_store/Cargo.toml @@ -34,6 +34,7 @@ async-trait = "0.1.53" bytes = "1.0" chrono = { version = "0.4.34", default-features = false, features = ["clock"] } futures = "0.3" +http = "1.2.0" humantime = "2.1" itertools = "0.14.0" parking_lot = { version = "0.12" } @@ -46,7 +47,6 @@ walkdir = { version = "2", optional = true } # Cloud storage support base64 = { version = "0.22", default-features = false, features = ["std"], optional = true } form_urlencoded = { version = "1.2", optional = true } -http = { version = "1.2.0", optional = true } http-body-util = { version = "0.1", optional = true } httparse = { version = "1.8.0", default-features = false, features = ["std"], optional = true } hyper = { version = "1.2", default-features = false, optional = true } @@ -66,7 +66,7 @@ nix = { version = "0.29.0", features = ["fs"] } [features] default = ["fs"] -cloud = ["serde", "serde_json", "quick-xml", "hyper", "reqwest", "reqwest/stream", "chrono/serde", "base64", "rand", "ring", "dep:http", "http-body-util", "form_urlencoded", "serde_urlencoded"] +cloud = ["serde", "serde_json", "quick-xml", "hyper", "reqwest", "reqwest/stream", "chrono/serde", "base64", "rand", "ring", "http-body-util", "form_urlencoded", "serde_urlencoded"] azure = ["cloud", "httparse"] fs = ["walkdir"] gcp = ["cloud", "rustls-pemfile"] diff --git a/object_store/src/client/builder.rs b/object_store/src/client/builder.rs index 0fbc12fd948..fcbc6e8baee 100644 --- a/object_store/src/client/builder.rs +++ b/object_store/src/client/builder.rs @@ -92,6 +92,13 @@ impl HttpRequestBuilder { self } + pub(crate) fn extensions(mut self, extensions: ::http::Extensions) -> Self { + if let Ok(r) = &mut self.request { + *r.extensions_mut() = extensions; + } + self + } + pub(crate) fn header(mut self, name: K, value: V) -> Self where K: TryInto, diff --git a/object_store/src/client/mod.rs b/object_store/src/client/mod.rs index 4fe3cff159a..36252f54f18 100644 --- a/object_store/src/client/mod.rs +++ b/object_store/src/client/mod.rs @@ -718,27 +718,40 @@ impl GetOptionsExt for HttpRequestBuilder { fn with_get_options(mut self, options: GetOptions) -> Self { use hyper::header::*; - if let Some(range) = options.range { + let GetOptions { + if_match, + if_none_match, + if_modified_since, + if_unmodified_since, + range, + version: _, + head: _, + extensions, + } = options; + + if let Some(range) = range { self = self.header(RANGE, range.to_string()); } - if let Some(tag) = options.if_match { + if let Some(tag) = if_match { self = self.header(IF_MATCH, tag); } - if let Some(tag) = options.if_none_match { + if let Some(tag) = if_none_match { self = self.header(IF_NONE_MATCH, tag); } const DATE_FORMAT: &str = "%a, %d %b %Y %H:%M:%S GMT"; - if let Some(date) = options.if_unmodified_since { + if let Some(date) = if_unmodified_since { self = self.header(IF_UNMODIFIED_SINCE, date.format(DATE_FORMAT).to_string()); } - if let Some(date) = options.if_modified_since { + if let Some(date) = if_modified_since { self = self.header(IF_MODIFIED_SINCE, date.format(DATE_FORMAT).to_string()); } + self = self.extensions(extensions); + self } } diff --git a/object_store/src/lib.rs b/object_store/src/lib.rs index 58f757b2972..21352f5761e 100644 --- a/object_store/src/lib.rs +++ b/object_store/src/lib.rs @@ -967,6 +967,11 @@ pub struct GetOptions { /// /// pub head: bool, + /// Implementation-specific extensions. Intended for use by [`ObjectStore`] implementations + /// that need to pass context-specific information (like tracing spans) via trait methods. + /// + /// These extensions are ignored entirely by backends offered through this crate. + pub extensions: ::http::Extensions, } impl GetOptions {