aboutsummaryrefslogtreecommitdiff
path: root/src/api/s3_get.rs
diff options
context:
space:
mode:
authorQuentin <quentin@deuxfleurs.fr>2020-11-11 11:26:51 +0100
committerQuentin <quentin@deuxfleurs.fr>2020-11-11 11:26:51 +0100
commite31aa0f7dfb4c8f014ce65cdf749141d2a9fec21 (patch)
tree286920418940dc40b679cdf71627d7fe276f0fc1 /src/api/s3_get.rs
parentf01006a1f954cecb23085ceac5ec28f165a6f0d7 (diff)
parent045009da9b7ac4198574bd5aa256c11cfe4ae469 (diff)
downloadgarage-e31aa0f7dfb4c8f014ce65cdf749141d2a9fec21.tar.gz
garage-e31aa0f7dfb4c8f014ce65cdf749141d2a9fec21.zip
Merge branch 'master' into feature/refactor-s3
Diffstat (limited to 'src/api/s3_get.rs')
-rw-r--r--src/api/s3_get.rs15
1 files changed, 7 insertions, 8 deletions
diff --git a/src/api/s3_get.rs b/src/api/s3_get.rs
index 68558dbe..71c656f2 100644
--- a/src/api/s3_get.rs
+++ b/src/api/s3_get.rs
@@ -5,13 +5,13 @@ use futures::stream::*;
use hyper::body::Bytes;
use hyper::{Body, Request, Response, StatusCode};
-use garage_util::error::Error;
-
use garage_table::EmptyKey;
use garage_model::garage::Garage;
use garage_model::object_table::*;
+use crate::error::*;
+
fn object_headers(
version: &ObjectVersion,
version_meta: &ObjectVersionMeta,
@@ -111,11 +111,8 @@ pub async fn handle_get(
let range = match req.headers().get("range") {
Some(range) => {
- let range_str = range
- .to_str()
- .map_err(|e| Error::BadRequest(format!("Invalid range header: {}", e)))?;
- let mut ranges = http_range::HttpRange::parse(range_str, last_v_meta.size)
- .map_err(|_e| Error::BadRequest(format!("Invalid range")))?;
+ let range_str = range.to_str()?;
+ let mut ranges = http_range::HttpRange::parse(range_str, last_v_meta.size)?;
if ranges.len() > 1 {
return Err(Error::BadRequest(format!("Multiple ranges not supported")));
} else {
@@ -210,7 +207,9 @@ pub async fn handle_get_range(
let body: Body = Body::from(bytes[begin as usize..end as usize].to_vec());
Ok(resp_builder.body(body)?)
} else {
- Err(Error::Message(format!("Internal error: requested range not present in inline bytes when it should have been")))
+ None.ok_or_internal_error(
+ "Requested range not present in inline bytes when it should have been",
+ )
}
}
ObjectVersionData::FirstBlock(_meta, _first_block_hash) => {