Don't return error document for non-4xx errors
This commit is contained in:
parent
f231cff7e6
commit
17446e3b46
|
@ -139,11 +139,12 @@ async fn serve_file(garage: Arc<Garage>, req: &Request<Body>) -> Result<Response
|
|||
.map_err(Error::from);
|
||||
|
||||
if let Err(error) = ret_doc {
|
||||
if *req.method() == Method::HEAD {
|
||||
// For a HEAD method, we don't return the error document
|
||||
// as content. Here we just return the error code
|
||||
// and the error message in the body,
|
||||
// by relying on err_to_res that is called when we return an Err.
|
||||
if *req.method() == Method::HEAD || !error.http_status_code().is_client_error() {
|
||||
// Do not return the error document in the following cases:
|
||||
// - the error is not a 4xx error code
|
||||
// - the request is a HEAD method
|
||||
// In this case we just return the error code and the error message in the body,
|
||||
// by relying on err_to_res that is called above when we return an Err.
|
||||
return Err(error);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue