diff options
author | trinity-1686a <trinity.pointard@gmail.com> | 2021-11-29 11:52:42 +0100 |
---|---|---|
committer | Alex <alex@adnab.me> | 2021-11-29 11:52:42 +0100 |
commit | 7f26ed55cdad4a67300447cf92bf8e4975a5c978 (patch) | |
tree | 4b19ae34f53351bc4850a6c3ab2c04dfe87f10d3 /src/api/api_server.rs | |
parent | 8811bb08e6d5eb024bacdfbb20d039c6b696e1a6 (diff) | |
download | garage-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/api/api_server.rs')
-rw-r--r-- | src/api/api_server.rs | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/api/api_server.rs b/src/api/api_server.rs index 74142453..240ffca9 100644 --- a/src/api/api_server.rs +++ b/src/api/api_server.rs @@ -65,10 +65,15 @@ async fn handler( } Err(e) => { let body: Body = Body::from(e.aws_xml(&garage.config.s3_api.s3_region, uri.path())); - let http_error = Response::builder() + let mut http_error_builder = Response::builder() .status(e.http_status_code()) - .header("Content-Type", "application/xml") - .body(body)?; + .header("Content-Type", "application/xml"); + + if let Some(header_map) = http_error_builder.headers_mut() { + e.add_headers(header_map) + } + + let http_error = http_error_builder.body(body)?; if e.http_status_code().is_server_error() { warn!("Response: error {}, {}", e.http_status_code(), e); |