aboutsummaryrefslogtreecommitdiff
path: root/src/web/error.rs
diff options
context:
space:
mode:
authortrinity-1686a <trinity.pointard@gmail.com>2021-11-29 11:52:42 +0100
committerAlex <alex@adnab.me>2021-11-29 11:52:42 +0100
commit7f26ed55cdad4a67300447cf92bf8e4975a5c978 (patch)
tree4b19ae34f53351bc4850a6c3ab2c04dfe87f10d3 /src/web/error.rs
parent8811bb08e6d5eb024bacdfbb20d039c6b696e1a6 (diff)
downloadgarage-7f26ed55cdad4a67300447cf92bf8e4975a5c978.tar.gz
garage-7f26ed55cdad4a67300447cf92bf8e4975a5c978.zip
Improved handling of HTTP ranges
- correct HTTP code when range syntax is invalid (fix #140) - when multiple ranges are given, simply ignore and send whole file Co-authored-by: Trinity Pointard <trinity.pointard@gmail.com> Reviewed-on: https://git.deuxfleurs.fr/Deuxfleurs/garage/pulls/157 Reviewed-by: Alex <alex@adnab.me> Co-authored-by: trinity-1686a <trinity.pointard@gmail.com> Co-committed-by: trinity-1686a <trinity.pointard@gmail.com>
Diffstat (limited to 'src/web/error.rs')
-rw-r--r--src/web/error.rs11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/web/error.rs b/src/web/error.rs
index 426155c1..55990e9d 100644
--- a/src/web/error.rs
+++ b/src/web/error.rs
@@ -1,5 +1,6 @@
use err_derive::Error;
-use hyper::StatusCode;
+use hyper::header::HeaderValue;
+use hyper::{HeaderMap, StatusCode};
use garage_util::error::Error as GarageError;
@@ -47,4 +48,12 @@ impl Error {
_ => StatusCode::BAD_REQUEST,
}
}
+
+ pub fn add_headers(&self, header_map: &mut HeaderMap<HeaderValue>) {
+ #[allow(clippy::single_match)]
+ match self {
+ Error::ApiError(e) => e.add_headers(header_map),
+ _ => (),
+ }
+ }
}