add range header on 416 on web request
All checks were successful
continuous-integration/drone/pr Build is passing
All checks were successful
continuous-integration/drone/pr Build is passing
This commit is contained in:
parent
36e104b665
commit
8a43ede301
3 changed files with 12 additions and 1 deletions
|
@ -134,6 +134,7 @@ impl Error {
|
||||||
|
|
||||||
pub fn add_headers(&self, header_map: &mut HeaderMap<HeaderValue>) {
|
pub fn add_headers(&self, header_map: &mut HeaderMap<HeaderValue>) {
|
||||||
use hyper::header;
|
use hyper::header;
|
||||||
|
#[allow(clippy::single_match)]
|
||||||
match self {
|
match self {
|
||||||
Error::InvalidRange((_, len)) => {
|
Error::InvalidRange((_, len)) => {
|
||||||
header_map.append(
|
header_map.append(
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
use err_derive::Error;
|
use err_derive::Error;
|
||||||
use hyper::StatusCode;
|
use hyper::header::HeaderValue;
|
||||||
|
use hyper::{HeaderMap, StatusCode};
|
||||||
|
|
||||||
use garage_util::error::Error as GarageError;
|
use garage_util::error::Error as GarageError;
|
||||||
|
|
||||||
|
@ -47,4 +48,12 @@ impl Error {
|
||||||
_ => StatusCode::BAD_REQUEST,
|
_ => 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),
|
||||||
|
_ => (),
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,6 +62,7 @@ fn error_to_res(e: Error) -> Response<Body> {
|
||||||
let body: Body = Body::from(format!("{}\n", e));
|
let body: Body = Body::from(format!("{}\n", e));
|
||||||
let mut http_error = Response::new(body);
|
let mut http_error = Response::new(body);
|
||||||
*http_error.status_mut() = e.http_status_code();
|
*http_error.status_mut() = e.http_status_code();
|
||||||
|
e.add_headers(http_error.headers_mut());
|
||||||
http_error
|
http_error
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue