This is an automated email from the ASF dual-hosted git repository.
tustvold pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow-rs.git
The following commit(s) were added to refs/heads/master by this push:
new 407e575f41 Error if Remote Ignores HTTP Range Header (#4841)
407e575f41 is described below
commit 407e575f41365b73a84fb2a2150f918e6dab2bbe
Author: Cory Grinstead <[email protected]>
AuthorDate: Wed Sep 20 09:22:44 2023 -0500
Error if Remote Ignores HTTP Range Header (#4841)
* fix: abort http:get on !206 when issuing a range request
* add some comments
* pr feedback
* Update object_store/src/http/client.rs
Co-authored-by: Raphael Taylor-Davies
<[email protected]>
---------
Co-authored-by: Raphael Taylor-Davies
<[email protected]>
---
object_store/src/http/client.rs | 20 ++++++++++++++++++--
1 file changed, 18 insertions(+), 2 deletions(-)
diff --git a/object_store/src/http/client.rs b/object_store/src/http/client.rs
index 93cd4ee0ea..67a4129174 100644
--- a/object_store/src/http/client.rs
+++ b/object_store/src/http/client.rs
@@ -37,6 +37,9 @@ enum Error {
#[snafu(display("Request error: {}", source))]
Reqwest { source: reqwest::Error },
+ #[snafu(display("Range request not supported by {}", href))]
+ RangeNotSupported { href: String },
+
#[snafu(display("Error decoding PROPFIND response: {}", source))]
InvalidPropFind { source: quick_xml::de::DeError },
@@ -238,8 +241,9 @@ impl Client {
pub async fn get(&self, location: &Path, options: GetOptions) ->
Result<Response> {
let url = self.path_url(location);
let builder = self.client.get(url);
+ let has_range = options.range.is_some();
- builder
+ let res = builder
.with_get_options(options)
.send_retry(&self.retry_config)
.await
@@ -252,7 +256,19 @@ impl Client {
}
}
_ => Error::Request { source }.into(),
- })
+ })?;
+
+ // We expect a 206 Partial Content response if a range was requested
+ // a 200 OK response would indicate the server did not fulfill the
request
+ if has_range && res.status() != StatusCode::PARTIAL_CONTENT {
+ return Err(crate::Error::NotSupported {
+ source: Box::new(Error::RangeNotSupported {
+ href: location.to_string(),
+ }),
+ });
+ }
+
+ Ok(res)
}
pub async fn copy(&self, from: &Path, to: &Path, overwrite: bool) ->
Result<()> {