Skip to content
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

Error if Remote Ignores HTTP Range Header #4841

Merged
merged 4 commits into from
Sep 20, 2023
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions object_store/src/http/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 },

Expand Down Expand Up @@ -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
Expand All @@ -252,7 +256,20 @@ 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::OK {
universalmind303 marked this conversation as resolved.
Show resolved Hide resolved
return Err(crate::Error::Generic {
universalmind303 marked this conversation as resolved.
Show resolved Hide resolved
store: "HTTP",
source: Box::new(Error::RangeNotSupported {
href: location.to_string(),
}),
});
}

Ok(res)
}

pub async fn copy(&self, from: &Path, to: &Path, overwrite: bool) -> Result<()> {
Expand Down
Loading